diff --git a/Package.swift b/Package.swift index 4c6774c0..aec059cf 100644 --- a/Package.swift +++ b/Package.swift @@ -55,7 +55,7 @@ let package = Package( .package(url: "https://github.com/apple/swift-algorithms", from: "1.0.0"), // Read OpenAPI documents - .package(url: "https://github.com/mattpolzin/OpenAPIKit.git", exact: "3.0.0-rc.3"), + .package(url: "https://github.com/mattpolzin/OpenAPIKit.git", from: "3.0.0"), .package(url: "https://github.com/jpsim/Yams.git", "4.0.0"..<"6.0.0"), // CLI Tool diff --git a/Sources/_OpenAPIGeneratorCore/Translator/Content/ContentInspector.swift b/Sources/_OpenAPIGeneratorCore/Translator/Content/ContentInspector.swift index 053d13e3..d9a529d4 100644 --- a/Sources/_OpenAPIGeneratorCore/Translator/Content/ContentInspector.swift +++ b/Sources/_OpenAPIGeneratorCore/Translator/Content/ContentInspector.swift @@ -127,7 +127,8 @@ extension FileTranslator { let (contentType, contentValue) = mapWithContentTypes.first(where: { $0.type.isBinary }) { chosenContent = ( - contentType, .init(contentType: contentType, schema: .b(.string(format: .binary))), contentValue + contentType, .init(contentType: contentType, schema: .b(.string(contentEncoding: .binary))), + contentValue ) } else { diagnostics.emitUnsupported("Unsupported content", foundIn: foundIn) @@ -185,7 +186,7 @@ extension FileTranslator { } if contentType.isUrlEncodedForm { return .init(contentType: contentType, schema: contentValue.schema) } if !excludeBinary, contentType.isBinary { - return .init(contentType: contentType, schema: .b(.string(format: .binary))) + return .init(contentType: contentType, schema: .b(.string(contentEncoding: .binary))) } diagnostics.emitUnsupported("Unsupported content", foundIn: foundIn) return nil diff --git a/Sources/_OpenAPIGeneratorCore/Translator/TypeAssignment/TypeMatcher.swift b/Sources/_OpenAPIGeneratorCore/Translator/TypeAssignment/TypeMatcher.swift index 253a027c..0cefe261 100644 --- a/Sources/_OpenAPIGeneratorCore/Translator/TypeAssignment/TypeMatcher.swift +++ b/Sources/_OpenAPIGeneratorCore/Translator/TypeAssignment/TypeMatcher.swift @@ -302,10 +302,7 @@ struct TypeMatcher { case .binary: typeName = .body case .base64: typeName = .base64 default: - // Check the format as well, for docs converted from OpenAPI 3.0. switch core.format { - case .binary: typeName = .body - case .byte: typeName = .base64 case .dateTime: typeName = .date default: typeName = .string } diff --git a/Tests/OpenAPIGeneratorCoreTests/Translator/TypeAssignment/Test_TypeMatcher.swift b/Tests/OpenAPIGeneratorCoreTests/Translator/TypeAssignment/Test_TypeMatcher.swift index c85ccf42..8b8ddd1c 100644 --- a/Tests/OpenAPIGeneratorCoreTests/Translator/TypeAssignment/Test_TypeMatcher.swift +++ b/Tests/OpenAPIGeneratorCoreTests/Translator/TypeAssignment/Test_TypeMatcher.swift @@ -24,10 +24,8 @@ final class Test_TypeMatcher: Test_Core { } static let builtinTypes: [(JSONSchema, String)] = [ - (.string, "Swift.String"), (.string(.init(format: .binary), .init()), "OpenAPIRuntime.HTTPBody"), - (.string(.init(), .init(contentEncoding: .binary)), "OpenAPIRuntime.HTTPBody"), - (.string(.init(format: .byte), .init()), "OpenAPIRuntime.Base64EncodedData"), - (.string(.init(), .init(contentEncoding: .base64)), "OpenAPIRuntime.Base64EncodedData"), + (.string, "Swift.String"), (.string(contentEncoding: .binary), "OpenAPIRuntime.HTTPBody"), + (.string(contentEncoding: .base64), "OpenAPIRuntime.Base64EncodedData"), (.string(.init(format: .date), .init()), "Swift.String"), (.string(.init(format: .dateTime), .init()), "Foundation.Date"), diff --git a/Tests/OpenAPIGeneratorReferenceTests/Resources/Docs/petstore.yaml b/Tests/OpenAPIGeneratorReferenceTests/Resources/Docs/petstore.yaml index 4b906dea..b881e7e6 100644 --- a/Tests/OpenAPIGeneratorReferenceTests/Resources/Docs/petstore.yaml +++ b/Tests/OpenAPIGeneratorReferenceTests/Resources/Docs/petstore.yaml @@ -219,7 +219,7 @@ paths: content: application/octet-stream: schema: - format: binary + contentEncoding: binary type: string responses: '200': @@ -227,7 +227,7 @@ paths: content: application/octet-stream: schema: - format: binary + contentEncoding: binary type: string '412': description: Avatar is not acceptable @@ -284,7 +284,7 @@ components: genome: description: "Pet genome (base64-encoded)" type: string - format: byte + contentEncoding: base64 kind: $ref: '#/components/schemas/PetKind' MixedAnyOf: @@ -329,7 +329,7 @@ components: type: string genome: type: string - format: byte + contentEncoding: base64 Pets: type: array items: diff --git a/Tests/OpenAPIGeneratorReferenceTests/SnippetBasedReferenceTests.swift b/Tests/OpenAPIGeneratorReferenceTests/SnippetBasedReferenceTests.swift index 8e235888..d2441ba8 100644 --- a/Tests/OpenAPIGeneratorReferenceTests/SnippetBasedReferenceTests.swift +++ b/Tests/OpenAPIGeneratorReferenceTests/SnippetBasedReferenceTests.swift @@ -1121,7 +1121,7 @@ final class SnippetBasedReferenceTests: XCTestCase { schemas: MyData: type: string - format: byte + contentEncoding: base64 """, """ public enum Schemas { @@ -1140,7 +1140,7 @@ final class SnippetBasedReferenceTests: XCTestCase { properties: stuff: type: string - format: byte + contentEncoding: base64 """, """ public enum Schemas { @@ -2481,7 +2481,7 @@ final class SnippetBasedReferenceTests: XCTestCase { application/json: schema: type: string - format: byte + contentEncoding: base64 examples: application/json: summary: "a hello response"