Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for OpenAPI 3.0.4 and 3.1.1 #665

Merged
merged 3 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ let package = Package(
.package(url: "https://github.com/apple/swift-algorithms", from: "1.2.0"),

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

// CLI Tool
Expand Down
4 changes: 2 additions & 2 deletions Sources/_OpenAPIGeneratorCore/Parser/YamsParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ public struct YamsParser: ParserProtocol {
do {
let document: OpenAPIKit.OpenAPI.Document
switch openAPIVersion {
case "3.0.0", "3.0.1", "3.0.2", "3.0.3":
case "3.0.0", "3.0.1", "3.0.2", "3.0.3", "3.0.4":
let openAPI30Document = try decoder.decode(OpenAPIKit30.OpenAPI.Document.self, from: input.contents)
document = openAPI30Document.convert(to: .v3_1_0)
case "3.1.0": document = try decoder.decode(OpenAPIKit.OpenAPI.Document.self, from: input.contents)
case "3.1.0", "3.1.1": document = try decoder.decode(OpenAPIKit.OpenAPI.Document.self, from: input.contents)
default:
throw Diagnostic.openAPIVersionError(
versionString: "openapi: \(openAPIVersion)",
Expand Down
2 changes: 2 additions & 0 deletions Tests/OpenAPIGeneratorCoreTests/Parser/Test_YamsParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ final class Test_YamsParser: Test_Core {
XCTAssertNoThrow(try _test(openAPIVersionString: "3.0.1"))
XCTAssertNoThrow(try _test(openAPIVersionString: "3.0.2"))
XCTAssertNoThrow(try _test(openAPIVersionString: "3.0.3"))
XCTAssertNoThrow(try _test(openAPIVersionString: "3.0.4"))
XCTAssertNoThrow(try _test(openAPIVersionString: "3.1.0"))
XCTAssertNoThrow(try _test(openAPIVersionString: "3.1.1"))

let expected1 =
"/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."
Expand Down