From d29efee65d24b772bed8ecc1acad521cd8a5a8d1 Mon Sep 17 00:00:00 2001 From: Honza Dvorsky Date: Wed, 13 Sep 2023 09:11:18 +0200 Subject: [PATCH] Bump OpenAPIKit to beta.5 --- Package.swift | 2 +- Sources/_OpenAPIGeneratorCore/Parser/validateDoc.swift | 7 ++++++- .../OpenAPIGeneratorCoreTests/Parser/Test_YamsParser.swift | 5 +++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Package.swift b/Package.swift index ea7ec6e9..f9391217 100644 --- a/Package.swift +++ b/Package.swift @@ -64,7 +64,7 @@ let package = Package( // Read OpenAPI documents .package( url: "https://github.com/mattpolzin/OpenAPIKit.git", - exact: "3.0.0-beta.3" + exact: "3.0.0-beta.5" ), .package( url: "https://github.com/jpsim/Yams.git", diff --git a/Sources/_OpenAPIGeneratorCore/Parser/validateDoc.swift b/Sources/_OpenAPIGeneratorCore/Parser/validateDoc.swift index 589f6ef0..49f541fc 100644 --- a/Sources/_OpenAPIGeneratorCore/Parser/validateDoc.swift +++ b/Sources/_OpenAPIGeneratorCore/Parser/validateDoc.swift @@ -12,6 +12,8 @@ // //===----------------------------------------------------------------------===// +import OpenAPIKit + /// Runs validation steps on the incoming OpenAPI document. /// - Parameters: /// - doc: The OpenAPI document to validate. @@ -27,7 +29,10 @@ func validateDoc(_ doc: ParsedOpenAPIRepresentation, config: Config) throws -> [ // block the generator from running. // Validation errors continue to be fatal, such as // structural issues, like non-unique operationIds, etc. - let warnings = try doc.validate(strict: false) + let warnings = try doc.validate( + using: Validator().validating(.operationsContainResponses), + strict: false + ) let diagnostics: [Diagnostic] = warnings.map { warning in .warning( message: "Validation warning: \(warning.description)", diff --git a/Tests/OpenAPIGeneratorCoreTests/Parser/Test_YamsParser.swift b/Tests/OpenAPIGeneratorCoreTests/Parser/Test_YamsParser.swift index 9b7d5901..e3ee513b 100644 --- a/Tests/OpenAPIGeneratorCoreTests/Parser/Test_YamsParser.swift +++ b/Tests/OpenAPIGeneratorCoreTests/Parser/Test_YamsParser.swift @@ -123,7 +123,7 @@ final class Test_YamsParser: Test_Core { /foo.yaml: error: Found neither a $ref nor a PathItem in Document.paths['/system']. PathItem could not be decoded because: - Expected to find `responses` key for the **GET** endpoint under `/system` but it is missing.. + Inconsistency encountered when parsing `Vendor Extension` for the **GET** endpoint under `/system`: Found at least one vendor extension property that does not begin with the required 'x-' prefix. Invalid properties: [ resonance ].. """ assertThrownError(try _test(yaml), expectedDiagnostic: expected) } @@ -148,7 +148,8 @@ final class Test_YamsParser: Test_Core { ) { XCTAssertThrowsError(try closure(), file: file, line: line) { error in if let exitError = error as? Diagnostic { - XCTAssertEqual(exitError.localizedDescription, expectedDiagnostic, file: file, line: line) + let actualDiagnostic = exitError.localizedDescription + XCTAssertEqual(actualDiagnostic, expectedDiagnostic, file: file, line: line) } else { XCTFail("Thrown error is \(type(of: error)) but should be Diagnostic", file: file, line: line) }