OasOperation
OasOperation is an object representing an OpenAPI operation.
In addition to standard OpenAPI Operation object properties, it contains the api operation path
and method
.
Properties
Property | Type | Description |
---|---|---|
oasType | 'operation' | Static value representing the OpenAPI operation type. |
path | string | Operation path |
method | string | Lowercase HTTP method |
operationId | string | undefined | Optional operation id |
description | string | undefined | Optional description |
tags | string[] | undefined | Optional list of string tags which can be used to group operations |
parameters | (OasParameter | OasRef<'parameter'>)[] | undefined | Optional array of path, query, header or cookie OasParameter or references to them. |
requestBody | OasRequestBody | OasRef<'requestBody'> | undefined | Optional OasRequestBody or reference to it. |
responses | Record<string, OasResponse | OasRef<'response'>> | Record of OasResponse or references to them by HTTP status code. |
pathItem | OasPathItem | OasPathItem with meta data about the path. |
deprecated | boolean | undefined | Optional flag marking the operation as deprecated. |
extensionFields | Record<string, unknown> | undefined | Optional map of custom fields defined by OpenAPI extensions. Keys are strings beginning with x- and values are of any valid JSON type. |
Methods
toSuccessResponse
Returns the first response with a status code of 2xx or 'default' if no such response exists.
operation.toSuccessResponse()
Return value
An OasResponse or OasRef object.
toRequestBody
Get the request body schema for the given media type.
operation.toRequestBody( mediaType = 'application/json')
Parameters
Property | Type | Description |
---|---|---|
mediaType | string | Media type of the request body. Defaults to application/json . |
Return value
An OasSchema or OasRef object.
toParams
Get all resolved parameters for the operation.
operation.toParams( filter )
Parameters
Property | Type | Description |
---|---|---|
filter | `('path' | 'header' |
Return value
An array of OasParameter objects.
toParametersObject
Get all resolved parameters for the operation as an OasObject.
operation.toParametersObject( filter )
Parameters
Property | Type | Description |
---|---|---|
filter | `("path" | "header" |
Return value
An OasObject containing all resolved parameters for the operation.