Operations
Operations are essentially service endpoints, characterized by an operation name, parameters, and a return type.
You can declare operations using the op
keyword. Its name must be an identifier
.
Parameters
The parameters of an operation represent a model. Therefore, you can perform any action with parameters that you can with a model, including the use of the spread operator:
Return type
Frequently, an endpoint may return one of several possible models. For instance, there could be a return type for when an item is located, and another for when it isnβt. Unions are employed to express this scenario:
Reusing operations
You can reuse operation signatures with the is
keyword. For example, given an operation
You can reuse its signature like so:
This implies that deletePet
will inherit the same parameters, return type, and decorators as the Delete
operation.
This practice is typically used in conjunction with operation templates
Operation templates
For more information on templates, see templates.
You can reference the operation template using is
:
Referencing model properties
You can reference model properties using the .
operator for identifiers.
Meta type references
Certain operation meta types can be referenced using ::
Name | Example | Description |
---|---|---|
parameters | readPet::parameters | References the parameters model expression |
returnType | readPet::returnType | References the operation return type |