CodeSquared docs

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

PropertyTypeDescription
oasType'operation'Static value representing the OpenAPI operation type.
pathstringOperation path
methodstringLowercase HTTP method
operationIdstring | undefinedOptional operation id
descriptionstring | undefinedOptional description
tagsstring[] | undefinedOptional list of string tags which can be used to group operations
parameters(OasParameter | OasRef<'parameter'>)[] | undefinedOptional array of path, query, header or cookie OasParameter or references to them.
requestBodyOasRequestBody | OasRef<'requestBody'> | undefinedOptional OasRequestBody or reference to it.
responsesRecord<string, OasResponse | OasRef<'response'>>Record of OasResponse or references to them by HTTP status code.
pathItemOasPathItemOasPathItem with meta data about the path.
deprecatedboolean | undefinedOptional flag marking the operation as deprecated.
extensionFieldsRecord<string, unknown> | undefinedOptional 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
PropertyTypeDescription
mediaTypestringMedia 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
PropertyTypeDescription
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
PropertyTypeDescription
filter`("path""header"

Return value

An OasObject containing all resolved parameters for the operation.