Skip to content

OpenAPI_Content

mattpolzin edited this page Sep 28, 2020 · 9 revisions

OpenAPI.Content

OpenAPI Spec "Media Type Object"

public struct Content: Equatable, CodableVendorExtendable

See OpenAPI Media Type Object.

Inheritance

CodableVendorExtendable, Decodable, Encodable, Equatable, LocallyDereferenceable

Nested Type Aliases

Map

public typealias Map = OrderedDictionary<OpenAPI.ContentType, OpenAPI.Content>

Initializers

init(schema:example:encoding:vendorExtensions:)

Create Content with a schema, a reference to a schema, or no schema at all and optionally provide a single example.

public init(schema: Either<JSONReference<JSONSchema>, JSONSchema>?, example: AnyCodable? = nil, encoding: OrderedDictionary<String, Encoding>? = nil, vendorExtensions: [String: AnyCodable] = [:])

init(schemaReference:example:encoding:vendorExtensions:)

Create Content with a reference to a schema and optionally provide a single example.

public init(schemaReference: JSONReference<JSONSchema>, example: AnyCodable? = nil, encoding: OrderedDictionary<String, Encoding>? = nil, vendorExtensions: [String: AnyCodable] = [:])

init(schema:example:encoding:vendorExtensions:)

Create Content with a schema and optionally provide a single example.

public init(schema: JSONSchema, example: AnyCodable? = nil, encoding: OrderedDictionary<String, Encoding>? = nil, vendorExtensions: [String: AnyCodable] = [:])

init(schema:examples:encoding:vendorExtensions:)

Create Content with a schema, a reference to a schema, or no schema at all and optionally provide a map of examples.

public init(schema: Either<JSONReference<JSONSchema>, JSONSchema>?, examples: Example.Map?, encoding: OrderedDictionary<String, Encoding>? = nil, vendorExtensions: [String: AnyCodable] = [:])

init(schemaReference:examples:encoding:vendorExtensions:)

Create Content with a reference to a schema and optionally provide a map of examples.

public init(schemaReference: JSONReference<JSONSchema>, examples: Example.Map?, encoding: OrderedDictionary<String, Encoding>? = nil, vendorExtensions: [String: AnyCodable] = [:])

init(schema:examples:encoding:vendorExtensions:)

Create Content with a schema and optionally provide a map of examples.

public init(schema: JSONSchema, examples: Example.Map?, encoding: OrderedDictionary<String, Encoding>? = nil, vendorExtensions: [String: AnyCodable] = [:])

init(from:)

public init(from decoder: Decoder) throws

Properties

schema

var schema: Either<JSONReference<JSONSchema>, JSONSchema>?

example

var example: AnyCodable?

examples

var examples: Example.Map?

encoding

var encoding: OrderedDictionary<String, Encoding>?

vendorExtensions

Dictionary of vendor extensions.

var vendorExtensions: [String: AnyCodable]

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

Methods

firstExample(from:)

Pulls the first (inlined, not referenced) example found in the example dictionary given.

internal static func firstExample(from exampleDict: OpenAPI.Example.Map) -> AnyCodable?

Operates on a dictionary with values that may be either an Example or a reference to and example.

firstExample(from:)

Pulls the first example found in the example dictionary given.

internal static func firstExample(from exampleDict: OrderedDictionary<String, OpenAPI.Example>) -> AnyCodable?

encode(to:)

public func encode(to encoder: Encoder) throws

dereferenced(in:)

Create a DereferencedContent if all references in the content can be found in the given Components Object.

public func dereferenced(in components: OpenAPI.Components) throws -> DereferencedContent

Throws

ReferenceError.cannotLookupRemoteReference or ReferenceError.missingOnLookup(name:key:) depending on whether an unresolvable reference points to another file or just points to a component in the same file that cannot be found in the Components Object.

Types
Protocols
Global Functions
Extensions
Clone this wiki locally