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

Bump to OpenAPIKit 3.0.0 #362

Merged
merged 1 commit into from
Nov 6, 2023
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 @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,15 @@ paths:
content:
application/octet-stream:
schema:
format: binary
contentEncoding: binary
type: string
responses:
'200':
description: Echoes avatar back
content:
application/octet-stream:
schema:
format: binary
contentEncoding: binary
type: string
'412':
description: Avatar is not acceptable
Expand Down Expand Up @@ -284,7 +284,7 @@ components:
genome:
description: "Pet genome (base64-encoded)"
type: string
format: byte
contentEncoding: base64
kind:
$ref: '#/components/schemas/PetKind'
MixedAnyOf:
Expand Down Expand Up @@ -329,7 +329,7 @@ components:
type: string
genome:
type: string
format: byte
contentEncoding: base64
Pets:
type: array
items:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1121,7 +1121,7 @@ final class SnippetBasedReferenceTests: XCTestCase {
schemas:
MyData:
type: string
format: byte
contentEncoding: base64
""",
"""
public enum Schemas {
Expand All @@ -1140,7 +1140,7 @@ final class SnippetBasedReferenceTests: XCTestCase {
properties:
stuff:
type: string
format: byte
contentEncoding: base64
""",
"""
public enum Schemas {
Expand Down Expand Up @@ -2481,7 +2481,7 @@ final class SnippetBasedReferenceTests: XCTestCase {
application/json:
schema:
type: string
format: byte
contentEncoding: base64
examples:
application/json:
summary: "a hello response"
Expand Down