-
Notifications
You must be signed in to change notification settings - Fork 39
OpenAPI_Components
OpenAPI Spec "Components Object".
public struct Components: Equatable, CodableVendorExtendable
See OpenAPI Components Object.
This is a place to put reusable components to be referenced from other parts of the spec.
CodableVendorExtendable
, Decodable
, Encodable
, Equatable
init(schemas:responses:parameters:examples:requestBodies:headers:securitySchemes:links:callbacks:vendorExtensions:)
public init(
schemas: ComponentDictionary<JSONSchema> = [:],
responses: ComponentDictionary<Response> = [:],
parameters: ComponentDictionary<Parameter> = [:],
examples: ComponentDictionary<Example> = [:],
requestBodies: ComponentDictionary<Request> = [:],
headers: ComponentDictionary<Header> = [:],
securitySchemes: ComponentDictionary<SecurityScheme> = [:],
links: ComponentDictionary<Link> = [:],
callbacks: ComponentDictionary<Callbacks> = [:],
vendorExtensions: [String: AnyCodable] = [:]
)
public init(from decoder: Decoder) throws
public var schemas: ComponentDictionary<JSONSchema>
public var responses: ComponentDictionary<Response>
public var parameters: ComponentDictionary<Parameter>
public var examples: ComponentDictionary<Example>
public var requestBodies: ComponentDictionary<Request>
public var headers: ComponentDictionary<Header>
public var securitySchemes: ComponentDictionary<SecurityScheme>
public var callbacks: ComponentDictionary<Callbacks>
public var links: ComponentDictionary<Link>
Dictionary of vendor extensions.
public var vendorExtensions: [String: AnyCodable]
These should be of the form:
[ "x-extensionKey": <anything>]
where the values are anything codable.
An empty OpenAPI Components Object.
public static let noComponents: Components
public var isEmpty: Bool
The extension name used to store a Components Object name (the key something is stored under within the Components Object). This is used by OpenAPIKit to store the previous Component name of an OpenAPI Object that has been dereferenced (pulled out of the Components and stored inline in the OpenAPI Document).
public static let componentNameExtension: String = "x-component-name"
Check if the Components
contains the given reference or not.
public func contains<ReferenceType: Equatable & ComponentDictionaryLocatable>(_ reference: JSONReference<ReferenceType>) throws -> Bool
Look up a reference in this components dictionary. If you want a
non-throwing alternative, you can pull a JSONReference.InternalReference
out of your JSONReference
and pass that to contains
instead.
If the given reference cannot be checked against Components
then this method will throw ReferenceError
. This will occur when the given reference is a remote file reference.
Check if the Components
contains the given internal reference or not.
public func contains<ReferenceType: Equatable & ComponentDictionaryLocatable>(_ reference: JSONReference<ReferenceType>.InternalReference) -> Bool
Pass a reference to a component.
lookup()
will return the component value if it is found
in the Components Object.
public func lookup<ReferenceType: ComponentDictionaryLocatable>(_ reference: JSONReference<ReferenceType>) throws -> ReferenceType
If you want to look something up without throwing, you might want to use the subscript
operator on the Components
.
If you also want to fully dereference the value in question instead
of just looking it up see the various dereference
functions
on this type for more information.
ReferenceError.cannotLookupRemoteReference
or MissingReferenceError.referenceMissingOnLookup(name:)
depending on whether the reference points to another file or just points to a component in the same file that cannot be found in the Components Object.
Pass an Either
with a reference or a component.
lookup()
will return the component value if it is found
in the Components Object.
public func lookup<ReferenceType: ComponentDictionaryLocatable>(_ maybeReference: Either<JSONReference<ReferenceType>, ReferenceType>) throws -> ReferenceType
If you want to look something up without throwing, you might want to use the subscript
operator on the Components
.
If you also want to fully dereference the value in question instead
of just looking it up see the various dereference
functions
on this type for more information.
ReferenceError.cannotLookupRemoteReference
or MissingReferenceError.referenceMissingOnLookup(name:)
depending on whether the reference points to another file or just points to a component in the same file that cannot be found in the Components Object.
Create a JSONReference
.
public func reference<ReferenceType: ComponentDictionaryLocatable & Equatable>(named name: String, ofType: ReferenceType.Type) throws -> JSONReference<ReferenceType>
If the given name does not refer to an existing component of the given type.
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