Skip to content

Commit 759c30b

Browse files
authored
Add support for OpenAPI 3.0.4 and 3.1.1 (#665)
### Motivation OpenAPI 3.0.4 and 3.1.1 dropped, mostly containing clarifications: https://www.openapis.org/blog/2024/10/25/announcing-openapi-specification-patch-releases ### Modifications - Bumped the OpenAPIKit dependency to get the new versions parsed. - Added the two new versions to our enum. - Added unit tests. ### Result We can parse the new versions. ### Test Plan Added unit tests.
1 parent 827fa72 commit 759c30b

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ let package = Package(
5151
.package(url: "https://github.com/apple/swift-algorithms", from: "1.2.0"),
5252

5353
// Read OpenAPI documents
54-
.package(url: "https://github.com/mattpolzin/OpenAPIKit", from: "3.1.2"),
54+
.package(url: "https://github.com/mattpolzin/OpenAPIKit", from: "3.3.0"),
5555
.package(url: "https://github.com/jpsim/Yams", "4.0.0"..<"6.0.0"),
5656

5757
// CLI Tool

Sources/_OpenAPIGeneratorCore/Parser/YamsParser.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ public struct YamsParser: ParserProtocol {
7070
do {
7171
let document: OpenAPIKit.OpenAPI.Document
7272
switch openAPIVersion {
73-
case "3.0.0", "3.0.1", "3.0.2", "3.0.3":
73+
case "3.0.0", "3.0.1", "3.0.2", "3.0.3", "3.0.4":
7474
let openAPI30Document = try decoder.decode(OpenAPIKit30.OpenAPI.Document.self, from: input.contents)
7575
document = openAPI30Document.convert(to: .v3_1_0)
76-
case "3.1.0": document = try decoder.decode(OpenAPIKit.OpenAPI.Document.self, from: input.contents)
76+
case "3.1.0", "3.1.1": document = try decoder.decode(OpenAPIKit.OpenAPI.Document.self, from: input.contents)
7777
default:
7878
throw Diagnostic.openAPIVersionError(
7979
versionString: "openapi: \(openAPIVersion)",

Tests/OpenAPIGeneratorCoreTests/Parser/Test_YamsParser.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ final class Test_YamsParser: Test_Core {
2121
XCTAssertNoThrow(try _test(openAPIVersionString: "3.0.1"))
2222
XCTAssertNoThrow(try _test(openAPIVersionString: "3.0.2"))
2323
XCTAssertNoThrow(try _test(openAPIVersionString: "3.0.3"))
24+
XCTAssertNoThrow(try _test(openAPIVersionString: "3.0.4"))
2425
XCTAssertNoThrow(try _test(openAPIVersionString: "3.1.0"))
26+
XCTAssertNoThrow(try _test(openAPIVersionString: "3.1.1"))
2527

2628
let expected1 =
2729
"/foo.yaml: error: Unsupported document version: openapi: 3.2.0. Please provide a document with OpenAPI versions in the 3.0.x or 3.1.x sets."

0 commit comments

Comments
 (0)