Skip to content
Open
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
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ let package = Package(
.package(url: "https://github.com/apple/swift-collections", from: "1.1.4"),

// Read OpenAPI documents
.package(url: "https://github.com/mattpolzin/OpenAPIKit", from: "3.9.0"),
.package(url: "https://github.com/jpsim/Yams", "4.0.0"..<"7.0.0"),
.package(url: "https://github.com/mattpolzin/OpenAPIKit", from: "4.3.1"),
.package(url: "https://github.com/jpsim/Yams", "5.1.0"..<"7.0.0"),

// CLI Tool
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.3.0"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ extension FileTranslator {
// In nullable enum schemas, empty strings are parsed as Void.
// This is unlikely to be fixed, so handling that case here.
// https://github.com/apple/swift-openapi-generator/issues/118
if isNullable && anyValue is Void {
// Also handle nil values in nullable schemas.
let isNullValue = anyValue is Void || (anyValue as? String) == nil
if isNullable && isNullValue {
try addIfUnique(id: .string(""), caseName: context.safeNameGenerator.swiftMemberName(for: ""))
} else {
guard let rawValue = anyValue as? String else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,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:
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 ]..
Problem 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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ final class Test_TypeMatcher: Test_Core {
static let multipartElementTypeReferenceIfReferenceableTypes:
[(UnresolvedSchema?, OrderedDictionary<String, OpenAPI.Content.Encoding>?, String?)] = [
(nil, nil, nil), (.b(.string), nil, nil), (.a(.component(named: "Foo")), nil, "Foo"),
(.a(.component(named: "Foo")), ["foo": .init(contentType: .json)], nil),
(.a(.component(named: "Foo")), ["foo": .init(contentTypes: [.json])], nil),
]
func testMultipartElementTypeReferenceIfReferenceableTypes() throws {
for (schema, encoding, name) in Self.multipartElementTypeReferenceIfReferenceableTypes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Test_translateSchemas: Test_Core {
(
schemaWithWarnings,
[
"warning: Schema warning: Inconsistency encountered when parsing `OpenAPI Schema`: Found schema attributes not consistent with the type specified: string. Specifically, attributes for these other types: [\"array\"]. [context: codingPath=, contextString=, subjectName=OpenAPI Schema]"
"warning: Schema warning: Problem encountered when parsing `OpenAPI Schema`: Found schema attributes not consistent with the type specified: string. Specifically, attributes for these other types: [\"array\"]. [context: codingPath=, contextString=, subjectName=OpenAPI Schema]"
]
),
]
Expand Down
26 changes: 13 additions & 13 deletions Tests/OpenAPIGeneratorReferenceTests/CompatabilityTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ final class CompatibilityTest: XCTestCase {
"https://raw.githubusercontent.com/discourse/discourse_api_docs/8182f1b21ca62cc9ac85fd3a82cae8304033a672/openapi.yml",
license: .apache,
expectedDiagnostics: [
"Validation warning: Inconsistency encountered when parsing `OpenAPI Schema`: Found nothing but unsupported attributes..",
"Validation warning: Problem encountered when parsing `OpenAPI Schema`: Found nothing but unsupported attributes..",
"Multipart request bodies must always be required, but found an optional one - skipping. Mark as `required: true` to get this body generated.",
],
skipBuild: compatibilityTestSkipBuild
Expand All @@ -100,15 +100,15 @@ final class CompatibilityTest: XCTestCase {
"https://raw.githubusercontent.com/github/rest-api-description/322663c9c909974af16363b4dc0873c428bdbe34/descriptions-next/api.github.com/api.github.com.yaml",
license: .mit,
expectedDiagnostics: [
"Validation warning: Inconsistency encountered when parsing `OpenAPI Schema`: Found schema attributes not consistent with the type specified: array. Specifically, attributes for these other types: [\"object\"].",
"Validation warning: Inconsistency encountered when parsing `OpenAPI Schema`: Found schema attributes not consistent with the type specified: string. Specifically, attributes for these other types: [\"object\"].",
"Validation warning: Inconsistency encountered when parsing `OpenAPI Schema`: Found nothing but unsupported attributes..",
"Schema warning: Inconsistency encountered when parsing `OpenAPI Schema`: Found schema attributes not consistent with the type specified: string. Specifically, attributes for these other types: [\"array\"].",
"Validation warning: Inconsistency encountered when parsing `Schema`: A schema contains properties for multiple types of schemas, namely: [\"array\", \"object\"]..",
"Validation warning: Inconsistency encountered when parsing `OpenAPI Schema`: Found schema attributes not consistent with the type specified: string. Specifically, attributes for these other types: [\"array\"].",
"Validation warning: Problem encountered when parsing `OpenAPI Schema`: Found schema attributes not consistent with the type specified: array. Specifically, attributes for these other types: [\"object\"].",
"Validation warning: Problem encountered when parsing `OpenAPI Schema`: Found schema attributes not consistent with the type specified: string. Specifically, attributes for these other types: [\"object\"].",
"Validation warning: Problem encountered when parsing `OpenAPI Schema`: Found nothing but unsupported attributes..",
"Schema warning: Problem encountered when parsing `OpenAPI Schema`: Found schema attributes not consistent with the type specified: string. Specifically, attributes for these other types: [\"array\"].",
"Validation warning: Problem encountered when parsing `Schema`: A schema contains properties for multiple types of schemas, namely: [\"array\", \"object\"]..",
"Validation warning: Problem encountered when parsing `OpenAPI Schema`: Found schema attributes not consistent with the type specified: string. Specifically, attributes for these other types: [\"array\"].",
"A property name only appears in the required list, but not in the properties map - this is likely a typo; skipping this property.",
"Schema warning: Inconsistency encountered when parsing `OpenAPI Schema`: Found schema attributes not consistent with the type specified: array. Specifically, attributes for these other types: [\"object\"].",
"Schema warning: Inconsistency encountered when parsing `Schema`: A schema contains properties for multiple types of schemas, namely: [\"array\", \"object\"]..",
"Schema warning: Problem encountered when parsing `OpenAPI Schema`: Found schema attributes not consistent with the type specified: array. Specifically, attributes for these other types: [\"object\"].",
"Schema warning: Problem encountered when parsing `Schema`: A schema contains properties for multiple types of schemas, namely: [\"array\", \"object\"]..",
"Schema \"null\" is not supported, reason: \"schema type\", skipping",
],
skipBuild: true
Expand All @@ -121,11 +121,11 @@ final class CompatibilityTest: XCTestCase {
license: .mit,
expectedDiagnostics: [
"Multipart request bodies must always be required, but found an optional one - skipping. Mark as `required: true` to get this body generated.",
"Validation warning: Inconsistency encountered when parsing `OpenAPI Schema`: Found nothing but unsupported attributes..",
"Validation warning: Inconsistency encountered when parsing `OpenAPI Schema`: Found schema attributes not consistent with the type specified: string. Specifically, attributes for these other types: [\"array\"].",
"Validation warning: Problem encountered when parsing `OpenAPI Schema`: Found nothing but unsupported attributes..",
"Validation warning: Problem encountered when parsing `OpenAPI Schema`: Found schema attributes not consistent with the type specified: string. Specifically, attributes for these other types: [\"array\"].",
"A property name only appears in the required list, but not in the properties map - this is likely a typo; skipping this property.",
"Validation warning: Inconsistency encountered when parsing `OpenAPI Schema`: Found schema attributes not consistent with the type specified: string. Specifically, attributes for these other types: [\"object\"].",
"Schema warning: Inconsistency encountered when parsing `OpenAPI Schema`: Found schema attributes not consistent with the type specified: string. Specifically, attributes for these other types: [\"array\"].",
"Validation warning: Problem encountered when parsing `OpenAPI Schema`: Found schema attributes not consistent with the type specified: string. Specifically, attributes for these other types: [\"object\"].",
"Schema warning: Problem encountered when parsing `OpenAPI Schema`: Found schema attributes not consistent with the type specified: string. Specifically, attributes for these other types: [\"array\"].",
"Schema \"null\" is not supported, reason: \"schema type\", skipping",
],
skipBuild: true
Expand Down