Skip to content

OpenAPI_Parameter

mattpolzin edited this page Aug 21, 2023 · 8 revisions

OpenAPI.Parameter

OpenAPI Spec "Parameter Object"

public struct Parameter: Equatable, CodableVendorExtendable 

See OpenAPI Parameter Object.

Inheritance

CodableVendorExtendable, ComponentDictionaryLocatable, Decodable, Encodable, Equatable, LocallyDereferenceable

Nested Type Aliases

Array

An array of parameters that are Either Parameters or references to parameters.

public typealias Array = [Either<JSONReference<OpenAPI.Parameter>, OpenAPI.Parameter>]

You can use the lookup(_:) or subscript methods on the OpenAPI.Components found at document.components to resolve an Either to an OpenAPI.Parameter.

Initializers

init(name:context:schemaOrContent:description:deprecated:vendorExtensions:)

Create a parameter with an Either<SchemaContext, OpenAPI.Content.Map>.

public init(
            name: String,
            context: Context,
            schemaOrContent: Either<SchemaContext, OpenAPI.Content.Map>,
            description: String? = nil,
            deprecated: Bool = false,
            vendorExtensions: [String: AnyCodable] = [:]
        ) 

init(name:context:schema:description:deprecated:vendorExtensions:)

Create a parameter with a SchemaContext.

public init(
            name: String,
            context: Context,
            schema: SchemaContext,
            description: String? = nil,
            deprecated: Bool = false,
            vendorExtensions: [String: AnyCodable] = [:]
        ) 

init(name:context:schema:description:deprecated:vendorExtensions:)

Create a parameter with a JSONSchema and the default style for the given Context.

public init(
            name: String,
            context: Context,
            schema: JSONSchema,
            description: String? = nil,
            deprecated: Bool = false,
            vendorExtensions: [String: AnyCodable] = [:]
        ) 

init(name:context:schemaReference:description:deprecated:vendorExtensions:)

Create a parameter with a reference to a JSONSchema and the default style for the given Context.

public init(
            name: String,
            context: Context,
            schemaReference: JSONReference<JSONSchema>,
            description: String? = nil,
            deprecated: Bool = false,
            vendorExtensions: [String: AnyCodable] = [:]
        ) 

init(name:context:content:description:deprecated:vendorExtensions:)

Create a parameter with a Content.Map.

public init(
            name: String,
            context: Context,
            content: OpenAPI.Content.Map,
            description: String? = nil,
            deprecated: Bool = false,
            vendorExtensions: [String: AnyCodable] = [:]
        ) 

init(from:)

public init(from decoder: Decoder) throws 

Properties

openAPIComponentsKey

public static var openAPIComponentsKey: String 

openAPIComponentsKeyPath

public static var openAPIComponentsKeyPath: KeyPath<OpenAPI.Components, OpenAPI.ComponentDictionary<Self>> 

name

public var name: String

context

OpenAPI Spec "in" property determines the Context.

public var context: Context

This context stores the location (e.g. "query" or "header") of the parameter and any additional information relevant to parameters in the given location.

description

public var description: String?

deprecated

public var deprecated: Bool 

schemaOrContent

OpenAPI Spec "content" or "schema" properties.

public var schemaOrContent: Either<SchemaContext, OpenAPI.Content.Map>

You can access the schema context (if it is in use for this parameter) with schemaOrContent.schemaContextValue. The schema context contains lots of information detailed in the OpenAPI specification under the Parameter Object section.

You can directly access the underlying JSONSchema with schemaOrContent.schemaValue. If the schema is a reference instead of an inline value, schemaOrContent.schemaReference will get you the reference.

You can access the content map (if it is in use for this parameter) with schemaOrContent.contentValue.

vendorExtensions

Dictionary of vendor extensions.

public var vendorExtensions: [String: AnyCodable]

These should be of the form: [ "x-extensionKey": <anything>] where the values are anything codable.

required

public var required: Bool 

location

The location (e.g. "query") of the parameter.

public var location: Context.Location 

See the context property for more details on the parameter.

Methods

_dereferenced(in:following:dereferencedFromComponentNamed:)

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 -> DereferencedParameter 

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.

encode(to:)

public func encode(to encoder: Encoder) throws 
Types
Protocols
Global Functions
Extensions
Clone this wiki locally