Skip to content

Commit bc1d339

Browse files
authored
Merge pull request #387 from mattpolzin/oas-version-maintenance
OAS version maintenance
2 parents 446a10a + b73751a commit bc1d339

File tree

68 files changed

+142
-142
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+142
-142
lines changed

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
# OpenAPIKit <!-- omit in toc -->
66

7-
A library containing Swift types that encode to- and decode from [OpenAPI 3.0.x](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md) and [OpenAPI 3.1.x](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md) Documents and their components.
7+
A library containing Swift types that encode to- and decode from [OpenAPI 3.0.x](https://spec.openapis.org/oas/v3.0.4.html) and [OpenAPI 3.1.x](https://spec.openapis.org/oas/v3.1.1.html) Documents and their components.
88

99
OpenAPIKit follows semantic versioning despite the fact that the OpenAPI specificaiton does not. The following chart shows which OpenAPI specification versions and key features are supported by which OpenAPIKit versions.
1010

@@ -149,7 +149,7 @@ let newDoc: OpenAPIKit.OpenAPI.Document
149149

150150
oldDoc = try? JSONDecoder().decode(OpenAPI.Document.self, from: someFileData)
151151

152-
newDoc = oldDoc?.convert(to: .v3_1_0) ??
152+
newDoc = oldDoc?.convert(to: .v3_1_1) ??
153153
(try! JSONDecoder().decode(OpenAPI.Document.self, from: someFileData))
154154
// ^ Here we simply fall-back to 3.1.x if loading as 3.0.x failed. You could do a more
155155
// graceful job of this by determining up front which version to attempt to load or by
@@ -165,7 +165,7 @@ If retaining order is important for your use-case, I recommend the [**Yams**](ht
165165
The Foundation JSON encoding and decoding will be the most stable and battle-tested option with Yams as a pretty well established and stable option as well. FineJSON is lesser used (to my knowledge) but I have had success with it in the past.
166166

167167
### OpenAPI Document structure
168-
The types used by this library largely mirror the object definitions found in the OpenAPI specification [version 3.1.0](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md) (`OpenAPIKit` module) and [version 3.0.3](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md) (`OpenAPIKit30` module). The [Project Status](#project-status) lists each object defined by the spec and the name of the respective type in this library. The project status page currently focuses on OpenAPI 3.1.x but for the purposes of determining what things are named and what is supported you can mostly infer the status of the OpenAPI 3.0.x support as well.
168+
The types used by this library largely mirror the object definitions found in the OpenAPI specification [version 3.1.1](https://spec.openapis.org/oas/v3.1.1.html) (`OpenAPIKit` module) and [version 3.0.4](https://spec.openapis.org/oas/v3.0.4.html) (`OpenAPIKit30` module). The [Project Status](#project-status) lists each object defined by the spec and the name of the respective type in this library. The project status page currently focuses on OpenAPI 3.1.x but for the purposes of determining what things are named and what is supported you can mostly infer the status of the OpenAPI 3.0.x support as well.
169169

170170
#### Document Root
171171
At the root there is an `OpenAPI.Document`. In addition to some information that applies to the entire API, the document contains `OpenAPI.Components` (essentially a dictionary of reusable components that can be referenced with `JSONReferences` and `OpenAPI.References`) and an `OpenAPI.PathItem.Map` (a dictionary of routes your API defines).
@@ -289,7 +289,7 @@ let document = OpenAPI.Document(
289289
```
290290

291291
#### Specification Extensions
292-
Many OpenAPIKit types support [Specification Extensions](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#specification-extensions). As described in the OpenAPI Specification, these extensions must be objects that are keyed with the prefix "x-". For example, a property named "specialProperty" on the root OpenAPI Object (`OpenAPI.Document`) is invalid but the property "x-specialProperty" is a valid specification extension.
292+
Many OpenAPIKit types support [Specification Extensions](https://spec.openapis.org/oas/v3.1.1.html#specification-extensions). As described in the OpenAPI Specification, these extensions must be objects that are keyed with the prefix "x-". For example, a property named "specialProperty" on the root OpenAPI Object (`OpenAPI.Document`) is invalid but the property "x-specialProperty" is a valid specification extension.
293293

294294
You can get or set specification extensions via the `vendorExtensions` property on any object that supports this feature. The keys are `Strings` beginning with the aforementioned "x-" prefix and the values are `AnyCodable`. If you set an extension without using the "x-" prefix, the prefix will be added upon encoding.
295295

Sources/OpenAPIKit/Callbacks.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ extension OpenAPI {
1313
/// A map from runtime expressions to path items to be used as
1414
/// callbacks for the API. The OpenAPI Spec "Callback Object."
1515
///
16-
/// See [OpenAPI Callback Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#callback-object).
16+
/// See [OpenAPI Callback Object](https://spec.openapis.org/oas/v3.1.1.html#callback-object).
1717
///
1818
public typealias Callbacks = OrderedDictionary<CallbackURL, Either<OpenAPI.Reference<PathItem>, PathItem>>
1919

Sources/OpenAPIKit/Components Object/Components.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Foundation
1111
extension OpenAPI {
1212
/// OpenAPI Spec "Components Object".
1313
///
14-
/// See [OpenAPI Components Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#components-object).
14+
/// See [OpenAPI Components Object](https://spec.openapis.org/oas/v3.1.1.html#components-object).
1515
///
1616
/// This is a place to put reusable components to
1717
/// be referenced from other parts of the spec.

Sources/OpenAPIKit/Content/Content.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import OpenAPIKitCore
1010
extension OpenAPI {
1111
/// OpenAPI Spec "Media Type Object"
1212
///
13-
/// See [OpenAPI Media Type Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#media-type-object).
13+
/// See [OpenAPI Media Type Object](https://spec.openapis.org/oas/v3.1.1.html#media-type-object).
1414
public struct Content: Equatable, CodableVendorExtendable {
1515
public var schema: Either<OpenAPI.Reference<JSONSchema>, JSONSchema>?
1616
public var example: AnyCodable?

Sources/OpenAPIKit/Content/ContentEncoding.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import OpenAPIKitCore
1010
extension OpenAPI.Content {
1111
/// OpenAPI Spec "Encoding Object"
1212
///
13-
/// See [OpenAPI Encoding Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#encoding-object).
13+
/// See [OpenAPI Encoding Object](https://spec.openapis.org/oas/v3.1.1.html#encoding-object).
1414
public struct Encoding: Equatable {
1515
public typealias Style = OpenAPI.Parameter.SchemaContext.Style
1616

Sources/OpenAPIKit/Document/DereferencedDocument.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ extension DereferencedDocument {
105105
/// each path, traversed in the order the paths appear in
106106
/// the document.
107107
///
108-
/// See [Operation Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#operation-object) in the specifcation.
108+
/// See [Operation Object](https://spec.openapis.org/oas/v3.1.1.html#operation-object) in the specifcation.
109109
///
110110
public var allOperationIds: [String] {
111111
return paths.values

Sources/OpenAPIKit/Document/Document.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import OpenAPIKitCore
1010
extension OpenAPI {
1111
/// The root of an OpenAPI 3.1 document.
1212
///
13-
/// See [OpenAPI Specification](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md).
13+
/// See [OpenAPI Specification](https://spec.openapis.org/oas/v3.1.1.html).
1414
///
1515
/// An OpenAPI Document can say a _lot_ about the API it describes.
1616
/// A read-through of the specification is highly recommended because
@@ -100,7 +100,7 @@ extension OpenAPI {
100100
///
101101
/// Closely related to the callbacks feature, this section describes requests initiated other than by an API call, for example by an out of band registration.
102102
/// The key name is a unique string to refer to each webhook, while the (optionally referenced) Path Item Object describes a request that may be initiated by the API provider and the expected responses
103-
/// See [OpenAPI Webhook Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#fixed-fields)
103+
/// See [OpenAPI Webhook Object](https://spec.openapis.org/oas/v3.1.1.html#fixed-fields)
104104
public var webhooks: OrderedDictionary<String, Either<OpenAPI.Reference<OpenAPI.PathItem>, OpenAPI.PathItem>>
105105

106106
/// A declaration of which security mechanisms can be used across the API.
@@ -142,7 +142,7 @@ extension OpenAPI {
142142
public var vendorExtensions: [String: AnyCodable]
143143

144144
public init(
145-
openAPIVersion: Version = .v3_1_0,
145+
openAPIVersion: Version = .v3_1_1,
146146
info: Info,
147147
servers: [Server],
148148
paths: PathItem.Map,
@@ -229,7 +229,7 @@ extension OpenAPI.Document {
229229
/// each path, traversed in the order the paths appear in
230230
/// the document.
231231
///
232-
/// See [Operation Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#operation-object) in the specifcation.
232+
/// See [Operation Object](https://spec.openapis.org/oas/v3.1.1.html#operation-object) in the specifcation.
233233
///
234234
public var allOperationIds: [String] {
235235
return paths.values
@@ -413,7 +413,7 @@ extension OpenAPI {
413413
/// Multiple entries in this dictionary indicate all schemes named are
414414
/// required on the same request.
415415
///
416-
/// See [OpenAPI Security Requirement Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#security-requirement-object).
416+
/// See [OpenAPI Security Requirement Object](https://spec.openapis.org/oas/v3.1.1.html#security-requirement-object).
417417
public typealias SecurityRequirement = [JSONReference<SecurityScheme>: [String]]
418418
}
419419

Sources/OpenAPIKit/Document/DocumentInfo.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Foundation
1111
extension OpenAPI.Document {
1212
/// OpenAPI Spec "Info Object"
1313
///
14-
/// See [OpenAPI Info Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#info-object).
14+
/// See [OpenAPI Info Object](https://spec.openapis.org/oas/v3.1.1.html#info-object).
1515
public struct Info: Equatable, CodableVendorExtendable {
1616
public let title: String
1717
public let summary: String?
@@ -50,7 +50,7 @@ extension OpenAPI.Document {
5050

5151
/// OpenAPI Spec "Contact Object"
5252
///
53-
/// See [OpenAPI Contact Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#contact-object).
53+
/// See [OpenAPI Contact Object](https://spec.openapis.org/oas/v3.1.1.html#contact-object).
5454
public struct Contact: Equatable, CodableVendorExtendable {
5555
public let name: String?
5656
public let url: URL?
@@ -78,7 +78,7 @@ extension OpenAPI.Document {
7878

7979
/// OpenAPI Spec "License Object"
8080
///
81-
/// See [OpenAPI License Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#license-object).
81+
/// See [OpenAPI License Object](https://spec.openapis.org/oas/v3.1.1.html#license-object).
8282
public struct License: Equatable, CodableVendorExtendable {
8383
public let name: String
8484
public let identifier: Identifier?

Sources/OpenAPIKit/Example.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Foundation
1111
extension OpenAPI {
1212
/// OpenAPI Spec "Example Object"
1313
///
14-
/// See [OpenAPI Example Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#example-object).
14+
/// See [OpenAPI Example Object](https://spec.openapis.org/oas/v3.1.1.html#example-object).
1515
public struct Example: Equatable, CodableVendorExtendable {
1616
public let summary: String?
1717
public let description: String?

Sources/OpenAPIKit/ExternalDocumentation.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Foundation
1111
extension OpenAPI {
1212
/// OpenAPI Spec "External Documentation Object"
1313
///
14-
/// See [OpenAPI External Documentation Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#external-documentation-object).
14+
/// See [OpenAPI External Documentation Object](https://spec.openapis.org/oas/v3.1.1.html#external-documentation-object).
1515
public struct ExternalDocumentation: Equatable, CodableVendorExtendable {
1616
public var description: String?
1717
public var url: URL

Sources/OpenAPIKit/Header/Header.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import OpenAPIKitCore
1010
extension OpenAPI {
1111
/// OpenAPI Spec "Header Object"
1212
///
13-
/// See [OpenAPI Header Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#header-object).
13+
/// See [OpenAPI Header Object](https://spec.openapis.org/oas/v3.1.1.html#header-object).
1414
public struct Header: Equatable, CodableVendorExtendable {
1515
public typealias SchemaContext = Parameter.SchemaContext
1616

Sources/OpenAPIKit/Link.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import Foundation
1515
extension OpenAPI {
1616
/// OpenAPI Spec "Link Object"
1717
///
18-
/// See [OpenAPI Link Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#link-object).
18+
/// See [OpenAPI Link Object](https://spec.openapis.org/oas/v3.1.1.html#link-object).
1919
public struct Link: Equatable, CodableVendorExtendable {
2020
/// The **OpenAPI**` `operationRef` or `operationId` field, depending on whether
2121
/// a `URL` of a remote or local Operation Object or a `operationId` (String) of an
@@ -24,7 +24,7 @@ extension OpenAPI {
2424
/// A map from parameter names to either runtime expressions that evaluate to values or
2525
/// constant values (`AnyCodable`).
2626
///
27-
/// See the docuemntation for the [OpenAPI Link Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#link-object) for more details.
27+
/// See the docuemntation for the [OpenAPI Link Object](https://spec.openapis.org/oas/v3.1.1.html#link-object) for more details.
2828
///
2929
/// Empty dictionaries will be omitted from encoding.
3030
public var parameters: OrderedDictionary<String, Either<RuntimeExpression, AnyCodable>>

Sources/OpenAPIKit/Operation/Operation.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import OpenAPIKitCore
1010
extension OpenAPI {
1111
/// OpenAPI Spec "Operation Object"
1212
///
13-
/// See [OpenAPI Operation Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#operation-object).
13+
/// See [OpenAPI Operation Object](https://spec.openapis.org/oas/v3.1.1.html#operation-object).
1414
public struct Operation: Equatable, CodableVendorExtendable {
1515
public var tags: [String]?
1616
public var summary: String?

Sources/OpenAPIKit/Parameter/Parameter.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import OpenAPIKitCore
1010
extension OpenAPI {
1111
/// OpenAPI Spec "Parameter Object"
1212
///
13-
/// See [OpenAPI Parameter Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#parameter-object).
13+
/// See [OpenAPI Parameter Object](https://spec.openapis.org/oas/v3.1.1.html#parameter-object).
1414
public struct Parameter: Equatable, CodableVendorExtendable {
1515
public var name: String
1616

@@ -162,7 +162,7 @@ extension OpenAPI.Parameter {
162162
/// containing exactly the things that differentiate
163163
/// one parameter from another, per the specification.
164164
///
165-
/// See [Parameter Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#parameter-object).
165+
/// See [Parameter Object](https://spec.openapis.org/oas/v3.1.1.html#parameter-object).
166166
internal struct ParameterIdentity: Hashable {
167167
let name: String
168168
let location: Context.Location

Sources/OpenAPIKit/Parameter/ParameterContext.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import OpenAPIKitCore
1010
extension OpenAPI.Parameter {
1111
/// OpenAPI Spec "Parameter Object" location-specific configuration.
1212
///
13-
/// See [OpenAPI Parameter Locations](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#parameter-locations).
13+
/// See [OpenAPI Parameter Locations](https://spec.openapis.org/oas/v3.1.1.html#parameter-locations).
1414
///
1515
/// Query, Header, and Cookie parameters are
1616
/// all optional by default unless you pass

Sources/OpenAPIKit/Parameter/ParameterSchemaContext.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import OpenAPIKitCore
1010
extension OpenAPI.Parameter {
1111
/// OpenAPI Spec "Parameter Object" schema and style configuration.
1212
///
13-
/// See [OpenAPI Parameter Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#parameter-object)
14-
/// and [OpenAPI Style Values](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#style-values).
13+
/// See [OpenAPI Parameter Object](https://spec.openapis.org/oas/v3.1.1.html#parameter-object)
14+
/// and [OpenAPI Style Values](https://spec.openapis.org/oas/v3.1.1.html#style-values).
1515
public struct SchemaContext: Equatable {
1616
public var style: Style
1717
public var explode: Bool
@@ -132,7 +132,7 @@ extension OpenAPI.Parameter.SchemaContext.Style {
132132
/// per the OpenAPI Specification.
133133
///
134134
/// See the `style` fixed field under
135-
/// [OpenAPI Parameter Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#parameter-object).
135+
/// [OpenAPI Parameter Object](https://spec.openapis.org/oas/v3.1.1.html#parameter-object).
136136
public static func `default`(for location: OpenAPI.Parameter.Context) -> Self {
137137
switch location {
138138
case .query:

Sources/OpenAPIKit/Path Item/PathItem.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import OpenAPIKitCore
1010
extension OpenAPI {
1111
/// OpenAPI Spec "Path Item Object"
1212
///
13-
/// See [OpenAPI Path Item Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#path-item-object).
13+
/// See [OpenAPI Path Item Object](https://spec.openapis.org/oas/v3.1.1.html#path-item-object).
1414
///
1515
/// In addition to parameters that apply to all endpoints under the current path,
1616
/// this type offers access to each possible endpoint operation under properties

Sources/OpenAPIKit/Request/Request.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import OpenAPIKitCore
1010
extension OpenAPI {
1111
/// OpenAPI Spec "Request Body Object"
1212
///
13-
/// See [OpenAPI Request Body Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#request-body-object).
13+
/// See [OpenAPI Request Body Object](https://spec.openapis.org/oas/v3.1.1.html#request-body-object).
1414
public struct Request: Equatable, CodableVendorExtendable {
1515
public var description: String?
1616
public var content: Content.Map

Sources/OpenAPIKit/Response/Response.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import OpenAPIKitCore
1010
extension OpenAPI {
1111
/// OpenAPI Spec "Response Object"
1212
///
13-
/// See [OpenAPI Response Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#response-object).
13+
/// See [OpenAPI Response Object](https://spec.openapis.org/oas/v3.1.1.html#response-object).
1414
public struct Response: Equatable, CodableVendorExtendable {
1515
public var description: String
1616
public var headers: Header.Map?

Sources/OpenAPIKit/RuntimeExpression.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import OpenAPIKitCore
1010
extension OpenAPI {
1111
/// OpenAPI Spec "Runtime Expression"
1212
///
13-
/// See [OpenAPI Runtime Expression[(https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#runtime-expressions).
13+
/// See [OpenAPI Runtime Expression[(https://spec.openapis.org/oas/v3.1.1.html#runtime-expressions).
1414
///
1515
public enum RuntimeExpression: RawRepresentable, Equatable {
1616
case url

Sources/OpenAPIKit/Schema Object/JSONSchema.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import OpenAPIKitCore
99

1010
/// OpenAPI "Schema Object"
1111
///
12-
/// See [OpenAPI Schema Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#schema-object).
12+
/// See [OpenAPI Schema Object](https://spec.openapis.org/oas/v3.1.1.html#schema-object).
1313
public struct JSONSchema: JSONSchemaContext, HasWarnings {
1414

1515
public let warnings: [OpenAPI.Warning]

0 commit comments

Comments
 (0)