Skip to content

OpenAPI_Document

mattpolzin edited this page Jun 14, 2020 · 11 revisions

OpenAPI.Document

The root of an OpenAPI 3.0 document.

public struct Document: Equatable, CodableVendorExtendable

See OpenAPI Specification.

Inheritance

CodableVendorExtendable, Decodable, Encodable, Equatable

Initializers

init(openAPIVersion:info:servers:paths:components:security:tags:externalDocs:vendorExtensions:)

public init(openAPIVersion: Version = .v3_0_0, info: Info, servers: [Server], paths: PathItem.Map, components: Components, security: [SecurityRequirement] = [], tags: [Tag]? = nil, externalDocs: ExternalDocumentation? = nil, vendorExtensions: [String: AnyCodable] = [:])

init(from:)

public init(from decoder: Decoder) throws

Properties

openAPIVersion

var openAPIVersion: Version

info

var info: Info

servers

var servers: [Server]

paths

var paths: PathItem.Map

components

var components: Components

security

var security: [SecurityRequirement]

tags

var tags: [Tag]?

externalDocs

var externalDocs: ExternalDocumentation?

allOperationIds

Retrieve an array of all Operation Ids defined by this API. These Ids are guaranteed to be unique by the OpenAPI Specification.

var allOperationIds: [String]

See Operation Object in the specifcation.

vendorExtensions

Dictionary of vendor extensions.

var vendorExtensions: [String: AnyCodable]

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

routes

Get all routes for this document.

var routes: [Route]

Returns

An Array of Routes with the path and the definition of the route.

Methods

encode(to:)

public func encode(to encoder: Encoder) throws

validate(using:)

Validate this OpenAPI.Document.

public func validate(using validator: Validator = .init()) throws

Parameters

  • validator: - validator: Validator to use. By default, a validator that just asserts requirements of the OpenAPI Specification will be used.

Throws

ValidationErrors if any validations failed. EncodingError if encoding failed for a structural reason.

Types
Protocols
Global Functions
Extensions
Clone this wiki locally