Skip to content

Commit

Permalink
default to 3.1.1 when converting. pick up slightly outdated error mes…
Browse files Browse the repository at this point in the history
…sage change. straggling README changes
  • Loading branch information
mattpolzin committed Nov 1, 2024
1 parent 88162c7 commit 76f3d2f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ let newDoc: OpenAPIKit.OpenAPI.Document

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

newDoc = oldDoc?.convert(to: .v3_1_0) ??
newDoc = oldDoc?.convert(to: .v3_1_1) ??
(try! JSONDecoder().decode(OpenAPI.Document.self, from: someFileData))
// ^ Here we simply fall-back to 3.1.x if loading as 3.0.x failed. You could do a more
// graceful job of this by determining up front which version to attempt to load or by
Expand All @@ -165,7 +165,7 @@ If retaining order is important for your use-case, I recommend the [**Yams**](ht
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.

### OpenAPI Document structure
The types used by this library largely mirror the object definitions found in the OpenAPI specification [version 3.1.0](https://spec.openapis.org/oas/v3.1.1.html) (`OpenAPIKit` module) and [version 3.0.3](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.
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.

#### Document Root
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).
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenAPIKit/Schema Object/JSONSchemaContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ extension JSONSchema.CoreContext: Decodable {
.underlyingError(
InconsistencyError(
subjectName: "OpenAPI Schema",
details: "Found 'nullable' property. This property is not supported by OpenAPI v3.1.0. OpenAPIKit has translated it into 'type: [\"null\", ...]'.",
details: "Found 'nullable' property. This property is not supported by OpenAPI v3.1.x. OpenAPIKit has translated it into 'type: [\"null\", ...]'.",
codingPath: container.codingPath
)
)
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenAPIKitCompat/Compat30To31.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ private protocol To31 {
}

extension OpenAPIKit30.OpenAPI.Document {
fileprivate func to31(version: OpenAPIKit.OpenAPI.Document.Version = .v3_1_0) -> OpenAPIKit.OpenAPI.Document {
fileprivate func to31(version: OpenAPIKit.OpenAPI.Document.Version = .v3_1_1) -> OpenAPIKit.OpenAPI.Document {
OpenAPIKit.OpenAPI.Document(
openAPIVersion: version,
info: info.to31(),
Expand Down

0 comments on commit 76f3d2f

Please sign in to comment.