Skip to content

OpenAPI_PathItem

mattpolzin edited this page Aug 21, 2023 · 9 revisions

OpenAPI.PathItem

OpenAPI Spec "Path Item Object"

public struct PathItem: Equatable, CodableVendorExtendable 

See OpenAPI Path Item Object.

In addition to parameters that apply to all endpoints under the current path, this type offers access to each possible endpoint operation under properties named after the operation.

The GET operation, for example, is accessed via the .get property. You can also use the subscript operator, passing it the HTTPMethod you want to access.

You can access an array of equatable HttpMethod/Operation paris with the endpoints property.

Inheritance

CodableVendorExtendable, Decodable, Encodable, Equatable, LocallyDereferenceable

Nested Type Aliases

Map

public typealias Map = OrderedDictionary<OpenAPI.Path, OpenAPI.PathItem>

Initializers

init(summary:description:servers:parameters:get:put:post:delete:options:head:patch:trace:vendorExtensions:)

public init(
            summary: String? = nil,
            description: String? = nil,
            servers: [OpenAPI.Server]? = nil,
            parameters: Parameter.Array = [],
            get: Operation? = nil,
            put: Operation? = nil,
            post: Operation? = nil,
            delete: Operation? = nil,
            options: Operation? = nil,
            head: Operation? = nil,
            patch: Operation? = nil,
            trace: Operation? = nil,
            vendorExtensions: [String: AnyCodable] = [:]
        ) 

init(from:)

public init(from decoder: Decoder) throws 

Properties

summary

public var summary: String?

description

public var description: String?

servers

public var servers: [OpenAPI.Server]?

parameters

Parameters that apply to all operations at this path. See the parameters on each Operation for a complete picture of a given endpoint's parameters.

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.

get

The GET endpoint at this path, if one exists.

public var get: Operation?

put

The PUT endpoint at this path, if one exists.

public var put: Operation?

post

The POST endpoint at this path, if one exists.

public var post: Operation?

delete

The DELETE endpoint at this path, if one exists.

public var delete: Operation?

options

The OPTIONS endpoint at this path, if one exists.

public var options: Operation?

head

The HEAD endpoint at this path, if one exists.

public var head: Operation?

patch

The PATCH endpoint at this path, if one exists.

public var patch: Operation?

trace

The TRACE endpoint at this path, if one exists.

public var trace: Operation?

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.

endpoints

Get all endpoints defined at this path.

public var endpoints: [Endpoint] 

Returns

An array of Endpoints with the method (i.e. .get) and the operation for the method.

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

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.

get(_:)

Set the GET endpoint operation.

public mutating func get(_ op: Operation?) 

put(_:)

Set the PUT endpoint operation.

public mutating func put(_ op: Operation?) 

post(_:)

Set the POST endpoint operation.

public mutating func post(_ op: Operation?) 

delete(_:)

Set the DELETE endpoint operation.

public mutating func delete(_ op: Operation?) 

options(_:)

Set the OPTIONS endpoint operation.

public mutating func options(_ op: Operation?) 

head(_:)

Set the HEAD endpoint operation.

public mutating func head(_ op: Operation?) 

patch(_:)

Set the PATCH endpoint operation.

public mutating func patch(_ op: Operation?) 

trace(_:)

Set the TRACE endpoint operation.

public mutating func trace(_ op: Operation?) 

`for`(_:)

Retrieve the operation for the given verb, if one is set for this path.

public func `for`(_ verb: OpenAPI.HttpMethod) -> OpenAPI.Operation? 

set(operation:for:)

Set the operation for the given verb, overwriting any already set operation for the same verb.

public mutating func set(operation: OpenAPI.Operation?, for verb: OpenAPI.HttpMethod) 

encode(to:)

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