-
Notifications
You must be signed in to change notification settings - Fork 38
OpenAPI_Operation
OpenAPI Spec "Operation Object"
public struct Operation: Equatable, CodableVendorExtendable
CodableVendorExtendable
, Decodable
, Encodable
, Equatable
, LocallyDereferenceable
init(tags:summary:description:externalDocs:operationId:parameters:requestBody:responses:callbacks:deprecated:security:servers:vendorExtensions:)
Create an Operation with a request body specified by an
Either<JSONReference<OpenAPI.Request>, OpenAPI.Request>
.
public init(
tags: [String]? = nil,
summary: String? = nil,
description: String? = nil,
externalDocs: OpenAPI.ExternalDocumentation? = nil,
operationId: String? = nil,
parameters: Parameter.Array = [],
requestBody: Either<JSONReference<OpenAPI.Request>, OpenAPI.Request>,
responses: OpenAPI.Response.Map,
callbacks: OpenAPI.CallbacksMap = [:],
deprecated: Bool = false,
security: [OpenAPI.SecurityRequirement]? = nil,
servers: [OpenAPI.Server]? = nil,
vendorExtensions: [String: AnyCodable] = [:]
)
init(tags:summary:description:externalDocs:operationId:parameters:requestBody:responses:callbacks:deprecated:security:servers:vendorExtensions:)
Create an Operation that optionally specifies a request body.
public init(
tags: [String]? = nil,
summary: String? = nil,
description: String? = nil,
externalDocs: OpenAPI.ExternalDocumentation? = nil,
operationId: String? = nil,
parameters: Parameter.Array = [],
requestBody: OpenAPI.Request? = nil,
responses: OpenAPI.Response.Map,
callbacks: OpenAPI.CallbacksMap = [:],
deprecated: Bool = false,
security: [OpenAPI.SecurityRequirement]? = nil,
servers: [OpenAPI.Server]? = nil,
vendorExtensions: [String: AnyCodable] = [:]
)
init(tags:summary:description:externalDocs:operationId:parameters:requestBody:responses:callbacks:deprecated:security:servers:vendorExtensions:)
Create an Operation with a variadic list of tags as the first argument.
public init(
tags: String...,
summary: String? = nil,
description: String? = nil,
externalDocs: OpenAPI.ExternalDocumentation? = nil,
operationId: String? = nil,
parameters: Parameter.Array = [],
requestBody: OpenAPI.Request? = nil,
responses: OpenAPI.Response.Map,
callbacks: OpenAPI.CallbacksMap = [:],
deprecated: Bool = false,
security: [OpenAPI.SecurityRequirement]? = nil,
servers: [OpenAPI.Server]? = nil,
vendorExtensions: [String: AnyCodable] = [:]
)
public init(from decoder: Decoder) throws
public var tags: [String]?
public var summary: String?
public var description: String?
public var externalDocs: OpenAPI.ExternalDocumentation?
public var operationId: String?
Parameters that apply to this endpoint. See the parameters
on the PathItem
containing this endpoint as well for a
complete picture of the parameters this endpoint supports.
public var parameters: Parameter.Array
A Parameter.Array
is an array of "either parameter or
reference to parameter" entries. You can use the lookup(_:)
method on the OpenAPI.Components
found at
document.components
to resolve one of these entries to
an OpenAPI.Parameter
.
public var requestBody: Either<JSONReference<OpenAPI.Request>, OpenAPI.Request>?
The possible responses for this operation, keyed by status code.
public var responses: OpenAPI.Response.Map
The status code keys can be integer values, ranges, or even the
default
which just refers to the response to expect where no
other respones apply.
Because the map is ordered, you can access responses by either
status code or index. Notice that the values of this dictionary are actually
Either
an inline Response
or a reference to a Response
that is
defined elsewhere.
Example:
let firstResponse: (OpenAPI.Response.StatusCode, Either<JSONReference<OpenAPI.Response>, OpenAPI.Response>)
firstResponse = operation.responses[0]!
// literally documented as "200" status code:
let successResponse: Either<JSONReference<OpenAPI.Response>, OpenAPI.Response>
successResponse = operation.responses[status: 200]!
// documented as "2XX" status code:
let successResponse2: Either<JSONReference<OpenAPI.Response>, OpenAPI.Response>
successResponse2 = operation.responses[.range(.success)]!
If you want to access the response (assuming it is inlined) you need to grab
it out of the Either
.
Example:
let inlinedResponse = successResponse.responseValue
You can also look the response up in the Components
. For convenience, you
can ask to have the Either
looked up and the result will be the Response
regardless of whether the Response
was inlined or found in the Components
.
Example:
let foundResponse: OpenAPI.Response
foundResponse = document.components.lookup(successResponse)!
A map of possible out-of band callbacks related to the parent operation.
public let callbacks: OpenAPI.CallbacksMap
The key is a unique identifier for the Callback Object. Each value in the map is a Callback Object that describes a request that may be initiated by the API provider and the expected responses.
Indicates that the operation is deprecated or not.
public var deprecated: Bool
By default, deprecated
is false
.
If defined, overrides the security requirements in the
root OpenAPI.Document
security
array.
public var security: [OpenAPI.SecurityRequirement]?
Each secutity requirement in this array is an alternative, only one of which must be met for the request to be authorized.
By contrast, all entries in an individual SecurityRequirement
(which is itself a dictionary) must be met.
nil
indicates this operation uses the security requirements
defined at the root of the OpenAPI.Document
.
If defined, overrides the servers in the root of the
OpenAPI.Document
.
public var servers: [OpenAPI.Server]?
nil
indicates the operation uses the servers defined at the
root of the OpenAPI.Document
.
Dictionary of vendor extensions.
public var vendorExtensions: [String: AnyCodable]
These should be of the form:
[ "x-extensionKey": <anything>]
where the values are anything codable.
Get all response outcomes for this operation.
public var responseOutcomes: [ResponseOutcome]
An array of ResponseOutcomes
with the status and the response for the status.
An internal-use method that facilitates reference cycle detection by tracking past references followed in the course of dereferencing.
public func _dereferenced(
in components: OpenAPI.Components,
following references: Set<AnyHashable>,
dereferencedFromComponentNamed name: String?
) throws -> DereferencedOperation
For all external-use, see dereferenced(in:)
(provided by the LocallyDereferenceable
protocol).
All types that provide a _dereferenced(in:following:)
implementation have a dereferenced(in:)
implementation for free.
public func encode(to encoder: Encoder) throws
.
Types
- AnyCodable
- DereferencedContent
- DereferencedContentEncoding
- DereferencedDocument
- DereferencedDocument.Route
- DereferencedHeader
- DereferencedJSONSchema
- DereferencedJSONSchema.ArrayContext
- DereferencedJSONSchema.ObjectContext
- DereferencedOperation
- DereferencedOperation.ResponseOutcome
- DereferencedParameter
- DereferencedPathItem
- DereferencedPathItem.Endpoint
- DereferencedRequest
- DereferencedResponse
- DereferencedSchemaContext
- DereferencedSecurityRequirement
- DereferencedSecurityRequirement.ScopedScheme
- Either
- EitherDecodeNoTypesMatchedError
- EitherDecodeNoTypesMatchedError.IndividualFailure
- ErrorCategory
- ErrorCategory.KeyValue
- InconsistencyError
- JSONReference
- JSONReference.InternalReference
- JSONReference.Path
- JSONReference.PathComponent
- JSONSchema
- JSONSchema.ArrayContext
- JSONSchema.CoreContext
- JSONSchema.CoreContext.Permissions
- JSONSchema.IntegerContext
- JSONSchema.IntegerContext.Bound
- JSONSchema.NumericContext
- JSONSchema.NumericContext.Bound
- JSONSchema.ObjectContext
- JSONSchema.StringContext
- JSONSchemaResolutionError
- JSONType
- JSONTypeFormat
- JSONTypeFormat.AnyFormat
- JSONTypeFormat.ArrayFormat
- JSONTypeFormat.BooleanFormat
- JSONTypeFormat.IntegerFormat
- JSONTypeFormat.IntegerFormat.Extended
- JSONTypeFormat.NumberFormat
- JSONTypeFormat.ObjectFormat
- JSONTypeFormat.StringFormat
- JSONTypeFormat.StringFormat.Extended
- OpenAPI
- OpenAPI.CallbackURL
- OpenAPI.ComponentKey
- OpenAPI.Components
- OpenAPI.Components.ReferenceCycleError
- OpenAPI.Components.ReferenceError
- OpenAPI.Content
- OpenAPI.Content.Encoding
- OpenAPI.ContentType
- OpenAPI.Discriminator
- OpenAPI.Document
- OpenAPI.Document.Info
- OpenAPI.Document.Info.Contact
- OpenAPI.Document.Info.License
- OpenAPI.Document.Route
- OpenAPI.Document.Version
- OpenAPI.Error
- OpenAPI.Error.Decoding
- OpenAPI.Error.Decoding.Document
- OpenAPI.Error.Decoding.Document.Context
- OpenAPI.Error.Decoding.Operation
- OpenAPI.Error.Decoding.Operation.Context
- OpenAPI.Error.Decoding.Path
- OpenAPI.Error.Decoding.Path.Context
- OpenAPI.Error.Decoding.Request
- OpenAPI.Error.Decoding.Request.Context
- OpenAPI.Error.Decoding.Response
- OpenAPI.Error.Decoding.Response.Context
- OpenAPI.Example
- OpenAPI.ExternalDocumentation
- OpenAPI.Header
- OpenAPI.HttpMethod
- OpenAPI.Link
- OpenAPI.OAuthFlows
- OpenAPI.OAuthFlows.AuthorizationCode
- OpenAPI.OAuthFlows.ClientCredentials
- OpenAPI.OAuthFlows.CommonFields
- OpenAPI.OAuthFlows.Implicit
- OpenAPI.OAuthFlows.Password
- OpenAPI.Operation
- OpenAPI.Operation.ResponseOutcome
- OpenAPI.Parameter
- OpenAPI.Parameter.Context
- OpenAPI.Parameter.Context.Location
- OpenAPI.Parameter.SchemaContext
- OpenAPI.Parameter.SchemaContext.Style
- OpenAPI.Path
- OpenAPI.PathItem
- OpenAPI.PathItem.Endpoint
- OpenAPI.Request
- OpenAPI.Response
- OpenAPI.Response.StatusCode
- OpenAPI.Response.StatusCode.Range
- OpenAPI.RuntimeExpression
- OpenAPI.RuntimeExpression.Source
- OpenAPI.SecurityScheme
- OpenAPI.SecurityScheme.Location
- OpenAPI.SecurityScheme.SecurityType
- OpenAPI.SecurityScheme.SecurityType.Name
- OpenAPI.Server
- OpenAPI.Server.Variable
- OpenAPI.Tag
- OpenAPI.XML
- OrderedDictionary
- OrderedDictionary.Iterator
- ResolvedDocument
- ResolvedEndpoint
- ResolvedRoute
- URLTemplate
- URLTemplate.Component
- Validation
- ValidationContext
- ValidationError
- ValidationErrorCollection
- Validator
- Validator.CodingKey
Protocols
Global Functions
Extensions
- Array
- Bool
- Dictionary
- Double
- Float
- Int
- Int32
- Int64
- OpenAPI.Callbacks
- OpenAPI.Content.Encoding
- OpenAPI.Document.Info
- OpenAPI.Document.Info.Contact
- OpenAPI.Document.Info.License
- OpenAPI.Error.Decoding
- OpenAPI.Error.Decoding.Document
- OpenAPI.Error.Decoding.Operation
- OpenAPI.Error.Decoding.Path
- OpenAPI.Error.Decoding.Request
- OpenAPI.Error.Decoding.Response
- OpenAPI.OAuthFlows.AuthorizationCode
- OpenAPI.OAuthFlows.ClientCredentials
- OpenAPI.OAuthFlows.CommonFields
- OpenAPI.OAuthFlows.Implicit
- OpenAPI.OAuthFlows.Password
- OpenAPI.Parameter.Context
- OpenAPI.Parameter.SchemaContext
- OpenAPI.Response.StatusCode
- OpenAPI.Server.Variable
- Optional
- String
- URL
- UUID