Skip to content

DereferencedDocument

mattpolzin edited this page Jun 11, 2021 · 4 revisions

DereferencedDocument

An OpenAPI.Document type that guarantees its paths and security are inlined instead of referenced. You create a DereferencedDocument by calling the locallyDereferenced() method on an OpenAPI.Document.

@dynamicMemberLookup
public struct DereferencedDocument: Equatable 

Inheritance

Equatable

Properties

underlyingDocument

The original OpenAPI document prior to being dereferenced.

public let underlyingDocument: OpenAPI.Document

paths

This property maps the path of each route (OpenAPI.Path) to the documentation for that route (DereferencedPathItem).

public let paths: DereferencedPathItem.Map

security

A declaration of which security mechanisms can be used across the API.

public let security: [DereferencedSecurityRequirement]

The list of values includes alternative security requirement objects that can be used. Only one of the security requirement objects need to be satisfied to authorize a request. Individual operations can override this definition.

To make security optional, an empty security requirement can be included in the array.

routes

Get an array of all routes in the document. A route is the pairing of a path and the path item that describes the route at that path.

public var routes: [Route] 

Methods

resolved()

Resolve the document's routes and endpoints.

public func resolved() -> ResolvedDocument 

OpenAPI allows routes and endpoints to take on things like servers, parameters, and security requirements from various different locations in the OpenAPI.Document. A ResolvedDocument offers access to canonical routes and endpoints that collect and self-contain all necessary information about the given component.

Example

A particular GET endpoint takes its security requirements from the root OpenAPI security array, it takes a path item parameter from the PathItem it resides within, and it defines an additional query parameter.

The ResolvedEndpoint exposed by the ResolvedDocument will have the inherited security in its security array and it will have both the path and query parameters in its parameters array.

resolvedEndpoints()

Return all resolved endpoints for the whole document.

public func resolvedEndpoints() -> [ResolvedEndpoint] 

If you are working with resolved endpoints and routes the ResolvedDocument type might offer the best interface.

resolvedEndpointsByPath()

Returns all resolved endpoints for the whole document grouped by the paths for the routes containing them.

public func resolvedEndpointsByPath() -> OrderedDictionary<OpenAPI.Path, [ResolvedEndpoint]> 

If you are working with resolved endpoints and routes the ResolvedDocument type might offer the best interface.

resolvedRoutes()

Return all resolved routes for the whole document.

public func resolvedRoutes() -> [ResolvedRoute] 

If you are working with resolved endpoints and routes the ResolvedDocument type might offer the best interface.

resolvedRoutesByPath()

Returns all resolved routes for the whole document keyed by the paths each route is found at.

public func resolvedRoutesByPath() -> OrderedDictionary<OpenAPI.Path, ResolvedRoute> 

If you are working with resolved endpoints and routes the ResolvedDocument type might offer the best interface.

Types
Protocols
Global Functions
Extensions
Clone this wiki locally