From d003775bedf9fd93c4133c3e02a0a9f1a55a4676 Mon Sep 17 00:00:00 2001 From: Mathew Polzin Date: Mon, 12 May 2025 22:05:39 -0500 Subject: [PATCH 1/3] rename InconsistencyError to GenericError --- Sources/OpenAPIKit/CodableVendorExtendable.swift | 2 +- .../OpenAPIKit/Components Object/Components.swift | 2 +- Sources/OpenAPIKit/Content/Content.swift | 2 +- Sources/OpenAPIKit/Document/Document.swift | 6 +++--- .../DocumentDecodingError.swift | 6 +++--- .../OperationDecodingError.swift | 6 +++--- .../PathDecodingError.swift | 6 +++--- .../ResponseDecodingError.swift | 6 +++--- Sources/OpenAPIKit/Example.swift | 2 +- Sources/OpenAPIKit/Header/Header.swift | 4 ++-- Sources/OpenAPIKit/JSONReference.swift | 4 ++-- Sources/OpenAPIKit/Operation/Operation.swift | 2 +- Sources/OpenAPIKit/Parameter/Parameter.swift | 6 +++--- Sources/OpenAPIKit/Path Item/PathItem.swift | 2 +- Sources/OpenAPIKit/Request/Request.swift | 2 +- Sources/OpenAPIKit/Response/Response.swift | 2 +- Sources/OpenAPIKit/Schema Object/JSONSchema.swift | 6 +++--- .../OpenAPIKit/Schema Object/JSONSchemaContext.swift | 6 +++--- .../Utility/Container+DecodeURLAsString.swift | 4 ++-- Sources/OpenAPIKit30/CodableVendorExtendable.swift | 2 +- .../OpenAPIKit30/Components Object/Components.swift | 2 +- Sources/OpenAPIKit30/Content/Content.swift | 2 +- Sources/OpenAPIKit30/Document/Document.swift | 6 +++--- .../DocumentDecodingError.swift | 6 +++--- .../OperationDecodingError.swift | 6 +++--- .../PathDecodingError.swift | 4 ++-- .../ResponseDecodingError.swift | 6 +++--- Sources/OpenAPIKit30/Example.swift | 2 +- Sources/OpenAPIKit30/Header/Header.swift | 4 ++-- Sources/OpenAPIKit30/JSONReference.swift | 4 ++-- Sources/OpenAPIKit30/Operation/Operation.swift | 2 +- Sources/OpenAPIKit30/Parameter/Parameter.swift | 6 +++--- Sources/OpenAPIKit30/Path Item/PathItem.swift | 2 +- Sources/OpenAPIKit30/Request/Request.swift | 2 +- Sources/OpenAPIKit30/Response/Response.swift | 2 +- Sources/OpenAPIKit30/Schema Object/JSONSchema.swift | 6 +++--- .../Schema Object/JSONSchemaContext.swift | 6 +++--- .../Utility/Container+DecodeURLAsString.swift | 4 ++-- .../EitherDecodeNoTypesMatchedErrorExtensions.swift | 2 +- .../{InconsistencyError.swift => GenericError.swift} | 4 ++-- .../RequestDecodingError.swift | 6 +++--- Sources/OpenAPIKitCore/Shared/ComponentKey.swift | 4 ++-- .../OpenAPIKitCore/Shared/ResponseStatusCode.swift | 2 +- .../Utility/Container+DecodeURLAsString.swift | 4 ++-- .../Schema Object/SchemaFragmentCombiningTests.swift | 12 ++++++------ ...tencyErrorTests.swift => GenericErrorTests.swift} | 6 +++--- .../Schema Object/SchemaFragmentCombiningTests.swift | 12 ++++++------ 47 files changed, 101 insertions(+), 101 deletions(-) rename Sources/OpenAPIKitCore/Encoding and Decoding Errors And Warnings/{InconsistencyError.swift => GenericError.swift} (88%) rename Tests/OpenAPIKitCoreTests/{InconsistencyErrorTests.swift => GenericErrorTests.swift} (76%) diff --git a/Sources/OpenAPIKit/CodableVendorExtendable.swift b/Sources/OpenAPIKit/CodableVendorExtendable.swift index dc3b0b67b..a04516e5d 100644 --- a/Sources/OpenAPIKit/CodableVendorExtendable.swift +++ b/Sources/OpenAPIKit/CodableVendorExtendable.swift @@ -111,7 +111,7 @@ extension CodableVendorExtendable { let invalidKeys = extensions.keys.filter { !$0.lowercased().starts(with: "x-") } if !invalidKeys.isEmpty { let invalidKeysList = "[ " + invalidKeys.joined(separator: ", ") + " ]" - throw InconsistencyError( + throw GenericError( subjectName: "Vendor Extension", details: "Found at least one vendor extension property that does not begin with the required 'x-' prefix. Invalid properties: \(invalidKeysList)", codingPath: decoder.codingPath diff --git a/Sources/OpenAPIKit/Components Object/Components.swift b/Sources/OpenAPIKit/Components Object/Components.swift index de8556e83..284ca030f 100644 --- a/Sources/OpenAPIKit/Components Object/Components.swift +++ b/Sources/OpenAPIKit/Components Object/Components.swift @@ -220,7 +220,7 @@ extension OpenAPI.Components: Decodable { vendorExtensions = try Self.extensions(from: decoder) } catch let error as DecodingError { if let underlyingError = error.underlyingError as? KeyDecodingError { - throw InconsistencyError( + throw GenericError( subjectName: error.subjectName, details: underlyingError.localizedDescription, codingPath: error.codingPath diff --git a/Sources/OpenAPIKit/Content/Content.swift b/Sources/OpenAPIKit/Content/Content.swift index 928c90ac2..0d45bd53b 100644 --- a/Sources/OpenAPIKit/Content/Content.swift +++ b/Sources/OpenAPIKit/Content/Content.swift @@ -172,7 +172,7 @@ extension OpenAPI.Content: Decodable { let container = try decoder.container(keyedBy: CodingKeys.self) guard !(container.contains(.examples) && container.contains(.example)) else { - throw InconsistencyError( + throw GenericError( subjectName: "Example and Examples", details: "Only one of `example` and `examples` is allowed in the Media Type Object (`OpenAPI.Content`).", codingPath: container.codingPath diff --git a/Sources/OpenAPIKit/Document/Document.swift b/Sources/OpenAPIKit/Document/Document.swift index 8e5ee58df..fbd87d074 100644 --- a/Sources/OpenAPIKit/Document/Document.swift +++ b/Sources/OpenAPIKit/Document/Document.swift @@ -538,7 +538,7 @@ extension OpenAPI.Document: Decodable { } catch let error as OpenAPI.Error.Decoding.Path { throw OpenAPI.Error.Decoding.Document(error) - } catch let error as InconsistencyError { + } catch let error as GenericError { throw OpenAPI.Error.Decoding.Document(error) } catch let error as DecodingError { @@ -679,7 +679,7 @@ internal func decodeSecurityRequirements(from container: return (try? components.contains(ref)) ?? false } guard securityKeysAndValues.map({ $0.key }).allSatisfy(foundInComponents) else { - throw InconsistencyError( + throw GenericError( subjectName: key.stringValue, details: "Each key found in a Security Requirement dictionary must refer to a Security Scheme present in the Components dictionary", codingPath: container.codingPath + [key] @@ -728,7 +728,7 @@ internal func validate(securityRequirements: [OpenAPI.SecurityRequirement], at p ] .map(AnyCodingKey.init(stringValue:)) - throw InconsistencyError( + throw GenericError( subjectName: schemeKey, details: "Each key found in a Security Requirement dictionary must refer to a Security Scheme present in the Components dictionary", codingPath: keys diff --git a/Sources/OpenAPIKit/Encoding and Decoding Errors/DocumentDecodingError.swift b/Sources/OpenAPIKit/Encoding and Decoding Errors/DocumentDecodingError.swift index 6786b6034..d60ad1bff 100644 --- a/Sources/OpenAPIKit/Encoding and Decoding Errors/DocumentDecodingError.swift +++ b/Sources/OpenAPIKit/Encoding and Decoding Errors/DocumentDecodingError.swift @@ -14,7 +14,7 @@ extension OpenAPI.Error.Decoding { public enum Context: Sendable { case path(Path) - case inconsistency(InconsistencyError) + case inconsistency(GenericError) case other(Swift.DecodingError) case neither(EitherDecodeNoTypesMatchedError) } @@ -82,7 +82,7 @@ extension OpenAPI.Error.Decoding.Document { codingPath = error.codingPath } - internal init(_ error: InconsistencyError) { + internal init(_ error: GenericError) { context = .inconsistency(error) codingPath = error.codingPath } @@ -107,7 +107,7 @@ extension OpenAPI.Error.Decoding.Document: DiggingError { public init(unwrapping error: Swift.DecodingError) { if let decodingError = error.underlyingError as? Swift.DecodingError { self = Self(unwrapping: decodingError) - } else if let inconsistencyError = error.underlyingError as? InconsistencyError { + } else if let inconsistencyError = error.underlyingError as? GenericError { self = Self(inconsistencyError) } else if let pathError = error.underlyingError as? OpenAPI.Error.Decoding.Path { self = Self(pathError) diff --git a/Sources/OpenAPIKit/Encoding and Decoding Errors/OperationDecodingError.swift b/Sources/OpenAPIKit/Encoding and Decoding Errors/OperationDecodingError.swift index c62a3720a..355aea8e3 100644 --- a/Sources/OpenAPIKit/Encoding and Decoding Errors/OperationDecodingError.swift +++ b/Sources/OpenAPIKit/Encoding and Decoding Errors/OperationDecodingError.swift @@ -16,7 +16,7 @@ extension OpenAPI.Error.Decoding { public enum Context: Sendable { case request(Request) case response(Response) - case inconsistency(InconsistencyError) + case inconsistency(GenericError) case other(Swift.DecodingError) case neither(EitherDecodeNoTypesMatchedError) } @@ -95,7 +95,7 @@ extension OpenAPI.Error.Decoding.Operation { relativeCodingPath = Array(codingPath) } - internal init(_ error: InconsistencyError) { + internal init(_ error: GenericError) { var codingPath = error.codingPath.dropFirst(2) // this part of the coding path is structurally guaranteed to be an HTTP verb. let verb = OpenAPI.HttpMethod(rawValue: codingPath.removeFirst().stringValue.uppercased())! @@ -139,7 +139,7 @@ extension OpenAPI.Error.Decoding.Operation: DiggingError { self = Self(responseError) } else if let responseError = error.underlyingError as? OpenAPI.Error.Decoding.Response { self = Self(responseError) - } else if let inconsistencyError = error.underlyingError as? InconsistencyError { + } else if let inconsistencyError = error.underlyingError as? GenericError { self = Self(inconsistencyError) } else if let eitherError = error.underlyingError as? EitherDecodeNoTypesMatchedError { self = Self(eitherError) diff --git a/Sources/OpenAPIKit/Encoding and Decoding Errors/PathDecodingError.swift b/Sources/OpenAPIKit/Encoding and Decoding Errors/PathDecodingError.swift index 445604621..4de8c4e44 100644 --- a/Sources/OpenAPIKit/Encoding and Decoding Errors/PathDecodingError.swift +++ b/Sources/OpenAPIKit/Encoding and Decoding Errors/PathDecodingError.swift @@ -15,7 +15,7 @@ extension OpenAPI.Error.Decoding { public enum Context: Sendable { case endpoint(Operation) - case inconsistency(InconsistencyError) + case inconsistency(GenericError) case other(Swift.DecodingError) case neither(EitherDecodeNoTypesMatchedError) } @@ -120,7 +120,7 @@ extension OpenAPI.Error.Decoding.Path { relativeCodingPath = Array(codingPath) } - internal init(_ error: InconsistencyError) { + internal init(_ error: GenericError) { var codingPath = error.codingPath.dropFirst() let route = OpenAPI.Path(rawValue: codingPath.removeFirst().stringValue) @@ -165,7 +165,7 @@ extension OpenAPI.Error.Decoding.Path { // public init(unwrapping error: Swift.DecodingError) { // if let decodingError = error.underlyingError as? Swift.DecodingError { // self = Self(unwrapping: decodingError) -// } else if let inconsistencyError = error.underlyingError as? InconsistencyError { +// } else if let inconsistencyError = error.underlyingError as? GenericError { // self = Self(inconsistencyError) // } else if let eitherError = error.underlyingError as? EitherDecodeNoTypesMatchedError { // self = Self(eitherError) diff --git a/Sources/OpenAPIKit/Encoding and Decoding Errors/ResponseDecodingError.swift b/Sources/OpenAPIKit/Encoding and Decoding Errors/ResponseDecodingError.swift index 0089935d5..48259de94 100644 --- a/Sources/OpenAPIKit/Encoding and Decoding Errors/ResponseDecodingError.swift +++ b/Sources/OpenAPIKit/Encoding and Decoding Errors/ResponseDecodingError.swift @@ -14,7 +14,7 @@ extension OpenAPI.Error.Decoding { internal let relativeCodingPath: [CodingKey] public enum Context: Sendable { - case inconsistency(InconsistencyError) + case inconsistency(GenericError) case other(Swift.DecodingError) case neither(EitherDecodeNoTypesMatchedError) } @@ -68,7 +68,7 @@ extension OpenAPI.Error.Decoding.Response { return Array(path.dropFirst(responsesIndex.advanced(by: 1))) } - internal init(_ error: InconsistencyError) { + internal init(_ error: GenericError) { var codingPath = Self.relativePath(from: error.codingPath) let code = codingPath.removeFirst().stringValue.lowercased() @@ -114,7 +114,7 @@ extension OpenAPI.Error.Decoding.Response: DiggingError { public init(unwrapping error: Swift.DecodingError) { if let decodingError = error.underlyingError as? Swift.DecodingError { self = Self(unwrapping: decodingError) - } else if let inconsistencyError = error.underlyingError as? InconsistencyError { + } else if let inconsistencyError = error.underlyingError as? GenericError { self = Self(inconsistencyError) } else if let eitherError = error.underlyingError as? EitherDecodeNoTypesMatchedError { self = Self(eitherError) diff --git a/Sources/OpenAPIKit/Example.swift b/Sources/OpenAPIKit/Example.swift index d55528f93..ca2906881 100644 --- a/Sources/OpenAPIKit/Example.swift +++ b/Sources/OpenAPIKit/Example.swift @@ -117,7 +117,7 @@ extension OpenAPI.Example: Decodable { let container = try decoder.container(keyedBy: CodingKeys.self) guard !(container.contains(.externalValue) && container.contains(.value)) else { - throw InconsistencyError( + throw GenericError( subjectName: "example value", details: "Found both `value` and `externalValue` keys in an Example. You must specify one or the other.", codingPath: container.codingPath diff --git a/Sources/OpenAPIKit/Header/Header.swift b/Sources/OpenAPIKit/Header/Header.swift index 98765de53..2bff0fe4a 100644 --- a/Sources/OpenAPIKit/Header/Header.swift +++ b/Sources/OpenAPIKit/Header/Header.swift @@ -316,13 +316,13 @@ extension OpenAPI.Header: Decodable { case (nil, let schema?): schemaOrContent = .init(schema) case (nil, nil): - throw InconsistencyError( + throw GenericError( subjectName: "Header", details: "A header parameter must specify either `content` or `schema`", codingPath: decoder.codingPath ) case (_, _): - throw InconsistencyError( + throw GenericError( subjectName: "Header", details: "A header must specify one but not both `content` and `schema`", codingPath: decoder.codingPath diff --git a/Sources/OpenAPIKit/JSONReference.swift b/Sources/OpenAPIKit/JSONReference.swift index 3177fb2d3..4966193d1 100644 --- a/Sources/OpenAPIKit/JSONReference.swift +++ b/Sources/OpenAPIKit/JSONReference.swift @@ -461,7 +461,7 @@ extension JSONReference: Decodable { if referenceString.first == "#" { guard let internalReference = InternalReference(rawValue: referenceString) else { - throw InconsistencyError( + throw GenericError( subjectName: "JSON Reference", details: "Failed to parse a JSON Reference from '\(referenceString)'", codingPath: container.codingPath @@ -482,7 +482,7 @@ extension JSONReference: Decodable { externalReference = URL(string: referenceString) #endif guard let externalReference else { - throw InconsistencyError( + throw GenericError( subjectName: "JSON Reference", details: "Failed to parse a valid URI for a JSON Reference from '\(referenceString)'", codingPath: container.codingPath diff --git a/Sources/OpenAPIKit/Operation/Operation.swift b/Sources/OpenAPIKit/Operation/Operation.swift index cf9629059..7d30d823a 100644 --- a/Sources/OpenAPIKit/Operation/Operation.swift +++ b/Sources/OpenAPIKit/Operation/Operation.swift @@ -336,7 +336,7 @@ extension OpenAPI.Operation: Decodable { } catch let error as DecodingError { throw OpenAPI.Error.Decoding.Operation(unwrapping: error) - } catch let error as InconsistencyError { + } catch let error as GenericError { throw OpenAPI.Error.Decoding.Operation(error) } catch let error as EitherDecodeNoTypesMatchedError { diff --git a/Sources/OpenAPIKit/Parameter/Parameter.swift b/Sources/OpenAPIKit/Parameter/Parameter.swift index fc8f150a3..20b3843ad 100644 --- a/Sources/OpenAPIKit/Parameter/Parameter.swift +++ b/Sources/OpenAPIKit/Parameter/Parameter.swift @@ -298,7 +298,7 @@ extension OpenAPI.Parameter: Decodable { context = .header(required: required) case .path: if !required { - throw InconsistencyError( + throw GenericError( subjectName: name, details: "positional path parameters must be explicitly set to required", codingPath: decoder.codingPath @@ -324,13 +324,13 @@ extension OpenAPI.Parameter: Decodable { case (nil, let schema?): schemaOrContent = .init(schema) case (nil, nil): - throw InconsistencyError( + throw GenericError( subjectName: name, details: "A parameter must specify either `content` or `schema`", codingPath: decoder.codingPath ) case (_, _): - throw InconsistencyError( + throw GenericError( subjectName: name, details: "A parameter must specify one but not both `content` and `schema`", codingPath: decoder.codingPath diff --git a/Sources/OpenAPIKit/Path Item/PathItem.swift b/Sources/OpenAPIKit/Path Item/PathItem.swift index 6db744f78..a98654074 100644 --- a/Sources/OpenAPIKit/Path Item/PathItem.swift +++ b/Sources/OpenAPIKit/Path Item/PathItem.swift @@ -286,7 +286,7 @@ extension OpenAPI.PathItem: Decodable { } catch let error as DecodingError { throw OpenAPI.Error.Decoding.Path(error) - } catch let error as InconsistencyError { + } catch let error as GenericError { throw OpenAPI.Error.Decoding.Path(error) } catch let error as OpenAPI.Error.Decoding.Operation { diff --git a/Sources/OpenAPIKit/Request/Request.swift b/Sources/OpenAPIKit/Request/Request.swift index 58e1e01e3..08294e13b 100644 --- a/Sources/OpenAPIKit/Request/Request.swift +++ b/Sources/OpenAPIKit/Request/Request.swift @@ -123,7 +123,7 @@ extension OpenAPI.Request: Decodable { required = try container.decodeIfPresent(Bool.self, forKey: .required) ?? false vendorExtensions = try Self.extensions(from: decoder) - } catch let error as InconsistencyError { + } catch let error as GenericError { throw OpenAPI.Error.Decoding.Request(error) } catch let error as Swift.DecodingError { diff --git a/Sources/OpenAPIKit/Response/Response.swift b/Sources/OpenAPIKit/Response/Response.swift index d8b3f3000..af5d25365 100644 --- a/Sources/OpenAPIKit/Response/Response.swift +++ b/Sources/OpenAPIKit/Response/Response.swift @@ -186,7 +186,7 @@ extension OpenAPI.Response: Decodable { vendorExtensions = try Self.extensions(from: decoder) - } catch let error as InconsistencyError { + } catch let error as GenericError { throw OpenAPI.Error.Decoding.Response(error) } catch let error as EitherDecodeNoTypesMatchedError { diff --git a/Sources/OpenAPIKit/Schema Object/JSONSchema.swift b/Sources/OpenAPIKit/Schema Object/JSONSchema.swift index 5e3d4a6ab..8536fbab4 100644 --- a/Sources/OpenAPIKit/Schema Object/JSONSchema.swift +++ b/Sources/OpenAPIKit/Schema Object/JSONSchema.swift @@ -2049,7 +2049,7 @@ extension JSONSchema: Decodable { if keysFrom.count > 1 { _warnings.append( .underlyingError( - InconsistencyError( + GenericError( subjectName: "Schema", details: "A schema contains properties for multiple types of schemas, namely: \(keysFrom).", codingPath: decoder.codingPath @@ -2066,7 +2066,7 @@ extension JSONSchema: Decodable { if !keysFromElsewhere.isEmpty { _warnings.append( .underlyingError( - InconsistencyError( + GenericError( subjectName: "OpenAPI Schema", details: "Found schema attributes not consistent with the type specified: \(typeHint). Specifically, attributes for these other types: \(keysFromElsewhere)", codingPath: decoder.codingPath @@ -2124,7 +2124,7 @@ extension JSONSchema: Decodable { if fragmentContext.isEmpty && hintContainerCount > 0 { _warnings.append( .underlyingError( - InconsistencyError( + GenericError( subjectName: "OpenAPI Schema", details: "Found nothing but unsupported attributes.", codingPath: decoder.codingPath diff --git a/Sources/OpenAPIKit/Schema Object/JSONSchemaContext.swift b/Sources/OpenAPIKit/Schema Object/JSONSchemaContext.swift index fed5f4556..849595a18 100644 --- a/Sources/OpenAPIKit/Schema Object/JSONSchemaContext.swift +++ b/Sources/OpenAPIKit/Schema Object/JSONSchemaContext.swift @@ -987,7 +987,7 @@ extension JSONSchema.CoreContext: Decodable { case (true, false): _permissions = .readOnly case (true, true): - throw InconsistencyError( + throw GenericError( subjectName: "JSONSchema", details: "Either `readOnly` or `writeOnly` can be true but not both", codingPath: decoder.codingPath @@ -1033,7 +1033,7 @@ extension JSONSchema.CoreContext: Decodable { nullable = _nullable warnings.append( .underlyingError( - InconsistencyError( + GenericError( subjectName: "OpenAPI Schema", details: "Found 'nullable' property. This property is not supported by OpenAPI v3.1.x. OpenAPIKit has translated it into 'type: [\"null\", ...]'.", codingPath: container.codingPath @@ -1167,7 +1167,7 @@ extension JSONSchema.IntegerContext: Decodable { let value = try intAttempt ?? doubleAttempt.map { floatVal in guard let integer = Int(exactly: floatVal) else { - throw InconsistencyError( + throw GenericError( subjectName: max ? "maximum" : "minimum", details: "Expected an Integer literal but found a floating point value (\(String(describing: floatVal)))", codingPath: decoder.codingPath, diff --git a/Sources/OpenAPIKit/Utility/Container+DecodeURLAsString.swift b/Sources/OpenAPIKit/Utility/Container+DecodeURLAsString.swift index d750d99de..b9347662a 100644 --- a/Sources/OpenAPIKit/Utility/Container+DecodeURLAsString.swift +++ b/Sources/OpenAPIKit/Utility/Container+DecodeURLAsString.swift @@ -24,7 +24,7 @@ extension KeyedDecodingContainerProtocol { url = URL(string: string) #endif guard let url else { - throw InconsistencyError( + throw GenericError( subjectName: key.stringValue, details: "If specified, must be a valid URL", codingPath: codingPath @@ -51,7 +51,7 @@ extension KeyedDecodingContainerProtocol { url = URL(string: string) #endif guard let url else { - throw InconsistencyError( + throw GenericError( subjectName: key.stringValue, details: "If specified, must be a valid URL", codingPath: codingPath diff --git a/Sources/OpenAPIKit30/CodableVendorExtendable.swift b/Sources/OpenAPIKit30/CodableVendorExtendable.swift index dc3b0b67b..a04516e5d 100644 --- a/Sources/OpenAPIKit30/CodableVendorExtendable.swift +++ b/Sources/OpenAPIKit30/CodableVendorExtendable.swift @@ -111,7 +111,7 @@ extension CodableVendorExtendable { let invalidKeys = extensions.keys.filter { !$0.lowercased().starts(with: "x-") } if !invalidKeys.isEmpty { let invalidKeysList = "[ " + invalidKeys.joined(separator: ", ") + " ]" - throw InconsistencyError( + throw GenericError( subjectName: "Vendor Extension", details: "Found at least one vendor extension property that does not begin with the required 'x-' prefix. Invalid properties: \(invalidKeysList)", codingPath: decoder.codingPath diff --git a/Sources/OpenAPIKit30/Components Object/Components.swift b/Sources/OpenAPIKit30/Components Object/Components.swift index 929807d65..b804959e6 100644 --- a/Sources/OpenAPIKit30/Components Object/Components.swift +++ b/Sources/OpenAPIKit30/Components Object/Components.swift @@ -218,7 +218,7 @@ extension OpenAPI.Components: Decodable { vendorExtensions = try Self.extensions(from: decoder) } catch let error as DecodingError { if let underlyingError = error.underlyingError as? KeyDecodingError { - throw InconsistencyError( + throw GenericError( subjectName: error.subjectName, details: underlyingError.localizedDescription, codingPath: error.codingPath diff --git a/Sources/OpenAPIKit30/Content/Content.swift b/Sources/OpenAPIKit30/Content/Content.swift index 8ade49c91..01fadc36b 100644 --- a/Sources/OpenAPIKit30/Content/Content.swift +++ b/Sources/OpenAPIKit30/Content/Content.swift @@ -172,7 +172,7 @@ extension OpenAPI.Content: Decodable { let container = try decoder.container(keyedBy: CodingKeys.self) guard !(container.contains(.examples) && container.contains(.example)) else { - throw InconsistencyError( + throw GenericError( subjectName: "Example and Examples", details: "Only one of `example` and `examples` is allowed in the Media Type Object (`OpenAPI.Content`).", codingPath: container.codingPath diff --git a/Sources/OpenAPIKit30/Document/Document.swift b/Sources/OpenAPIKit30/Document/Document.swift index c4bc3a127..defd4070a 100644 --- a/Sources/OpenAPIKit30/Document/Document.swift +++ b/Sources/OpenAPIKit30/Document/Document.swift @@ -522,7 +522,7 @@ extension OpenAPI.Document: Decodable { } catch let error as OpenAPI.Error.Decoding.Path { throw OpenAPI.Error.Decoding.Document(error) - } catch let error as InconsistencyError { + } catch let error as GenericError { throw OpenAPI.Error.Decoding.Document(error) } catch let error as DecodingError { @@ -651,7 +651,7 @@ internal func decodeSecurityRequirements(from container: return (try? components.contains(ref)) ?? false } guard securityKeysAndValues.map({ $0.key }).allSatisfy(foundInComponents) else { - throw InconsistencyError( + throw GenericError( subjectName: key.stringValue, details: "Each key found in a Security Requirement dictionary must refer to a Security Scheme present in the Components dictionary", codingPath: container.codingPath + [key] @@ -700,7 +700,7 @@ internal func validate(securityRequirements: [OpenAPI.SecurityRequirement], at p ] .map(AnyCodingKey.init(stringValue:)) - throw InconsistencyError( + throw GenericError( subjectName: schemeKey, details: "Each key found in a Security Requirement dictionary must refer to a Security Scheme present in the Components dictionary", codingPath: keys diff --git a/Sources/OpenAPIKit30/Encoding and Decoding Errors/DocumentDecodingError.swift b/Sources/OpenAPIKit30/Encoding and Decoding Errors/DocumentDecodingError.swift index 6786b6034..d60ad1bff 100644 --- a/Sources/OpenAPIKit30/Encoding and Decoding Errors/DocumentDecodingError.swift +++ b/Sources/OpenAPIKit30/Encoding and Decoding Errors/DocumentDecodingError.swift @@ -14,7 +14,7 @@ extension OpenAPI.Error.Decoding { public enum Context: Sendable { case path(Path) - case inconsistency(InconsistencyError) + case inconsistency(GenericError) case other(Swift.DecodingError) case neither(EitherDecodeNoTypesMatchedError) } @@ -82,7 +82,7 @@ extension OpenAPI.Error.Decoding.Document { codingPath = error.codingPath } - internal init(_ error: InconsistencyError) { + internal init(_ error: GenericError) { context = .inconsistency(error) codingPath = error.codingPath } @@ -107,7 +107,7 @@ extension OpenAPI.Error.Decoding.Document: DiggingError { public init(unwrapping error: Swift.DecodingError) { if let decodingError = error.underlyingError as? Swift.DecodingError { self = Self(unwrapping: decodingError) - } else if let inconsistencyError = error.underlyingError as? InconsistencyError { + } else if let inconsistencyError = error.underlyingError as? GenericError { self = Self(inconsistencyError) } else if let pathError = error.underlyingError as? OpenAPI.Error.Decoding.Path { self = Self(pathError) diff --git a/Sources/OpenAPIKit30/Encoding and Decoding Errors/OperationDecodingError.swift b/Sources/OpenAPIKit30/Encoding and Decoding Errors/OperationDecodingError.swift index c62a3720a..355aea8e3 100644 --- a/Sources/OpenAPIKit30/Encoding and Decoding Errors/OperationDecodingError.swift +++ b/Sources/OpenAPIKit30/Encoding and Decoding Errors/OperationDecodingError.swift @@ -16,7 +16,7 @@ extension OpenAPI.Error.Decoding { public enum Context: Sendable { case request(Request) case response(Response) - case inconsistency(InconsistencyError) + case inconsistency(GenericError) case other(Swift.DecodingError) case neither(EitherDecodeNoTypesMatchedError) } @@ -95,7 +95,7 @@ extension OpenAPI.Error.Decoding.Operation { relativeCodingPath = Array(codingPath) } - internal init(_ error: InconsistencyError) { + internal init(_ error: GenericError) { var codingPath = error.codingPath.dropFirst(2) // this part of the coding path is structurally guaranteed to be an HTTP verb. let verb = OpenAPI.HttpMethod(rawValue: codingPath.removeFirst().stringValue.uppercased())! @@ -139,7 +139,7 @@ extension OpenAPI.Error.Decoding.Operation: DiggingError { self = Self(responseError) } else if let responseError = error.underlyingError as? OpenAPI.Error.Decoding.Response { self = Self(responseError) - } else if let inconsistencyError = error.underlyingError as? InconsistencyError { + } else if let inconsistencyError = error.underlyingError as? GenericError { self = Self(inconsistencyError) } else if let eitherError = error.underlyingError as? EitherDecodeNoTypesMatchedError { self = Self(eitherError) diff --git a/Sources/OpenAPIKit30/Encoding and Decoding Errors/PathDecodingError.swift b/Sources/OpenAPIKit30/Encoding and Decoding Errors/PathDecodingError.swift index af865d31e..db6d15d95 100644 --- a/Sources/OpenAPIKit30/Encoding and Decoding Errors/PathDecodingError.swift +++ b/Sources/OpenAPIKit30/Encoding and Decoding Errors/PathDecodingError.swift @@ -15,7 +15,7 @@ extension OpenAPI.Error.Decoding { public enum Context: Sendable { case endpoint(Operation) - case inconsistency(InconsistencyError) + case inconsistency(GenericError) case other(Swift.DecodingError) case neither(EitherDecodeNoTypesMatchedError) } @@ -120,7 +120,7 @@ extension OpenAPI.Error.Decoding.Path { relativeCodingPath = Array(codingPath) } - internal init(_ error: InconsistencyError) { + internal init(_ error: GenericError) { var codingPath = error.codingPath.dropFirst() let route = OpenAPI.Path(rawValue: codingPath.removeFirst().stringValue) diff --git a/Sources/OpenAPIKit30/Encoding and Decoding Errors/ResponseDecodingError.swift b/Sources/OpenAPIKit30/Encoding and Decoding Errors/ResponseDecodingError.swift index 0089935d5..48259de94 100644 --- a/Sources/OpenAPIKit30/Encoding and Decoding Errors/ResponseDecodingError.swift +++ b/Sources/OpenAPIKit30/Encoding and Decoding Errors/ResponseDecodingError.swift @@ -14,7 +14,7 @@ extension OpenAPI.Error.Decoding { internal let relativeCodingPath: [CodingKey] public enum Context: Sendable { - case inconsistency(InconsistencyError) + case inconsistency(GenericError) case other(Swift.DecodingError) case neither(EitherDecodeNoTypesMatchedError) } @@ -68,7 +68,7 @@ extension OpenAPI.Error.Decoding.Response { return Array(path.dropFirst(responsesIndex.advanced(by: 1))) } - internal init(_ error: InconsistencyError) { + internal init(_ error: GenericError) { var codingPath = Self.relativePath(from: error.codingPath) let code = codingPath.removeFirst().stringValue.lowercased() @@ -114,7 +114,7 @@ extension OpenAPI.Error.Decoding.Response: DiggingError { public init(unwrapping error: Swift.DecodingError) { if let decodingError = error.underlyingError as? Swift.DecodingError { self = Self(unwrapping: decodingError) - } else if let inconsistencyError = error.underlyingError as? InconsistencyError { + } else if let inconsistencyError = error.underlyingError as? GenericError { self = Self(inconsistencyError) } else if let eitherError = error.underlyingError as? EitherDecodeNoTypesMatchedError { self = Self(eitherError) diff --git a/Sources/OpenAPIKit30/Example.swift b/Sources/OpenAPIKit30/Example.swift index b4e564ebd..28bfd5277 100644 --- a/Sources/OpenAPIKit30/Example.swift +++ b/Sources/OpenAPIKit30/Example.swift @@ -93,7 +93,7 @@ extension OpenAPI.Example: Decodable { let container = try decoder.container(keyedBy: CodingKeys.self) guard !(container.contains(.externalValue) && container.contains(.value)) else { - throw InconsistencyError( + throw GenericError( subjectName: "example value", details: "Found both `value` and `externalValue` keys in an Example. You must specify one or the other.", codingPath: container.codingPath diff --git a/Sources/OpenAPIKit30/Header/Header.swift b/Sources/OpenAPIKit30/Header/Header.swift index 219a80ce4..98b66f7f3 100644 --- a/Sources/OpenAPIKit30/Header/Header.swift +++ b/Sources/OpenAPIKit30/Header/Header.swift @@ -302,13 +302,13 @@ extension OpenAPI.Header: Decodable { case (nil, let schema?): schemaOrContent = .init(schema) case (nil, nil): - throw InconsistencyError( + throw GenericError( subjectName: "Header", details: "A header parameter must specify either `content` or `schema`", codingPath: decoder.codingPath ) case (_, _): - throw InconsistencyError( + throw GenericError( subjectName: "Header", details: "A header must specify one but not both `content` and `schema`", codingPath: decoder.codingPath diff --git a/Sources/OpenAPIKit30/JSONReference.swift b/Sources/OpenAPIKit30/JSONReference.swift index 8057bf6e9..a4d0d3574 100644 --- a/Sources/OpenAPIKit30/JSONReference.swift +++ b/Sources/OpenAPIKit30/JSONReference.swift @@ -325,7 +325,7 @@ extension JSONReference: Decodable { if referenceString.first == "#" { guard let internalReference = InternalReference(rawValue: referenceString) else { - throw InconsistencyError( + throw GenericError( subjectName: "JSON Reference", details: "Failed to parse a JSON Reference from '\(referenceString)'", codingPath: container.codingPath @@ -346,7 +346,7 @@ extension JSONReference: Decodable { externalReference = URL(string: referenceString) #endif guard let externalReference else { - throw InconsistencyError( + throw GenericError( subjectName: "JSON Reference", details: "Failed to parse a valid URI for a JSON Reference from '\(referenceString)'", codingPath: container.codingPath diff --git a/Sources/OpenAPIKit30/Operation/Operation.swift b/Sources/OpenAPIKit30/Operation/Operation.swift index 8d97ced60..57d2ec7c1 100644 --- a/Sources/OpenAPIKit30/Operation/Operation.swift +++ b/Sources/OpenAPIKit30/Operation/Operation.swift @@ -316,7 +316,7 @@ extension OpenAPI.Operation: Decodable { } catch let error as DecodingError { throw OpenAPI.Error.Decoding.Operation(unwrapping: error) - } catch let error as InconsistencyError { + } catch let error as GenericError { throw OpenAPI.Error.Decoding.Operation(error) } catch let error as EitherDecodeNoTypesMatchedError { diff --git a/Sources/OpenAPIKit30/Parameter/Parameter.swift b/Sources/OpenAPIKit30/Parameter/Parameter.swift index d69e0cb1e..a162e2e5f 100644 --- a/Sources/OpenAPIKit30/Parameter/Parameter.swift +++ b/Sources/OpenAPIKit30/Parameter/Parameter.swift @@ -282,7 +282,7 @@ extension OpenAPI.Parameter: Decodable { context = .header(required: required) case .path: if !required { - throw InconsistencyError( + throw GenericError( subjectName: name, details: "positional path parameters must be explicitly set to required", codingPath: decoder.codingPath @@ -308,13 +308,13 @@ extension OpenAPI.Parameter: Decodable { case (nil, let schema?): schemaOrContent = .init(schema) case (nil, nil): - throw InconsistencyError( + throw GenericError( subjectName: name, details: "A parameter must specify either `content` or `schema`", codingPath: decoder.codingPath ) case (_, _): - throw InconsistencyError( + throw GenericError( subjectName: name, details: "A parameter must specify one but not both `content` and `schema`", codingPath: decoder.codingPath diff --git a/Sources/OpenAPIKit30/Path Item/PathItem.swift b/Sources/OpenAPIKit30/Path Item/PathItem.swift index 518818192..3cbc5abc2 100644 --- a/Sources/OpenAPIKit30/Path Item/PathItem.swift +++ b/Sources/OpenAPIKit30/Path Item/PathItem.swift @@ -268,7 +268,7 @@ extension OpenAPI.PathItem: Decodable { } catch let error as DecodingError { throw OpenAPI.Error.Decoding.Path(error) - } catch let error as InconsistencyError { + } catch let error as GenericError { throw OpenAPI.Error.Decoding.Path(error) } catch let error as OpenAPI.Error.Decoding.Operation { diff --git a/Sources/OpenAPIKit30/Request/Request.swift b/Sources/OpenAPIKit30/Request/Request.swift index c0c9b5e20..6c15e3a09 100644 --- a/Sources/OpenAPIKit30/Request/Request.swift +++ b/Sources/OpenAPIKit30/Request/Request.swift @@ -113,7 +113,7 @@ extension OpenAPI.Request: Decodable { required = try container.decodeIfPresent(Bool.self, forKey: .required) ?? false vendorExtensions = try Self.extensions(from: decoder) - } catch let error as InconsistencyError { + } catch let error as GenericError { throw OpenAPI.Error.Decoding.Request(error) } catch let error as Swift.DecodingError { diff --git a/Sources/OpenAPIKit30/Response/Response.swift b/Sources/OpenAPIKit30/Response/Response.swift index 3af8733d5..cab4d79cd 100644 --- a/Sources/OpenAPIKit30/Response/Response.swift +++ b/Sources/OpenAPIKit30/Response/Response.swift @@ -176,7 +176,7 @@ extension OpenAPI.Response: Decodable { vendorExtensions = try Self.extensions(from: decoder) - } catch let error as InconsistencyError { + } catch let error as GenericError { throw OpenAPI.Error.Decoding.Response(error) } catch let error as EitherDecodeNoTypesMatchedError { diff --git a/Sources/OpenAPIKit30/Schema Object/JSONSchema.swift b/Sources/OpenAPIKit30/Schema Object/JSONSchema.swift index d53a086ad..32ce0889e 100644 --- a/Sources/OpenAPIKit30/Schema Object/JSONSchema.swift +++ b/Sources/OpenAPIKit30/Schema Object/JSONSchema.swift @@ -1823,7 +1823,7 @@ extension JSONSchema: Decodable { if keysFrom.count > 1 { _warnings.append( .underlyingError( - InconsistencyError( + GenericError( subjectName: "Schema", details: "A schema contains properties for multiple types of schemas, namely: \(keysFrom).", codingPath: decoder.codingPath @@ -1837,7 +1837,7 @@ extension JSONSchema: Decodable { if !keysFromElsewhere.isEmpty { _warnings.append( .underlyingError( - InconsistencyError( + GenericError( subjectName: "OpenAPI Schema", details: "Found schema attributes not consistent with the type specified: \(typeHint). Specifically, attributes for these other types: \(keysFromElsewhere)", codingPath: decoder.codingPath @@ -1876,7 +1876,7 @@ extension JSONSchema: Decodable { if fragmentContext.isEmpty && hintContainerCount > 0 { _warnings.append( .underlyingError( - InconsistencyError( + GenericError( subjectName: "OpenAPI Schema", details: "Found nothing but unsupported attributes.", codingPath: decoder.codingPath diff --git a/Sources/OpenAPIKit30/Schema Object/JSONSchemaContext.swift b/Sources/OpenAPIKit30/Schema Object/JSONSchemaContext.swift index c41485aea..7c9774881 100644 --- a/Sources/OpenAPIKit30/Schema Object/JSONSchemaContext.swift +++ b/Sources/OpenAPIKit30/Schema Object/JSONSchemaContext.swift @@ -781,7 +781,7 @@ extension JSONSchema.CoreContext: Decodable { case (true, false): _permissions = .readOnly case (true, true): - throw InconsistencyError( + throw GenericError( subjectName: "JSONSchema", details: "Either `readOnly` or `writeOnly` can be true but not both", codingPath: decoder.codingPath @@ -895,7 +895,7 @@ extension JSONSchema.IntegerContext: Decodable { let maximumAttempt = try maximumIntegerAttempt ?? maximumDoubleAttempt.map { floatMax in guard let integer = Int(exactly: floatMax) else { - throw InconsistencyError( + throw GenericError( subjectName: "maximum", details: "Expected an Integer literal but found a floating point value (\(String(describing: floatMax)))", codingPath: decoder.codingPath, @@ -910,7 +910,7 @@ extension JSONSchema.IntegerContext: Decodable { let minimumAttempt = try minimumIntegerAttempt ?? minimumDoubleAttempt.map { floatMin in guard let integer = Int(exactly: floatMin) else { - throw InconsistencyError( + throw GenericError( subjectName: "minimum", details: "Expected an Integer literal but found a floating point value (\(String(describing: floatMin)))", codingPath: decoder.codingPath, diff --git a/Sources/OpenAPIKit30/Utility/Container+DecodeURLAsString.swift b/Sources/OpenAPIKit30/Utility/Container+DecodeURLAsString.swift index 71e3f36a3..5b17ae003 100644 --- a/Sources/OpenAPIKit30/Utility/Container+DecodeURLAsString.swift +++ b/Sources/OpenAPIKit30/Utility/Container+DecodeURLAsString.swift @@ -24,7 +24,7 @@ extension KeyedDecodingContainerProtocol { url = URL(string: string) #endif guard let url else { - throw InconsistencyError( + throw GenericError( subjectName: key.stringValue, details: "If specified, must be a valid URL", codingPath: codingPath @@ -51,7 +51,7 @@ extension KeyedDecodingContainerProtocol { url = URL(string: string) #endif guard let url else { - throw InconsistencyError( + throw GenericError( subjectName: key.stringValue, details: "If specified, must be a valid URL", codingPath: codingPath diff --git a/Sources/OpenAPIKitCore/Encoding and Decoding Errors And Warnings/EitherDecodeNoTypesMatchedErrorExtensions.swift b/Sources/OpenAPIKitCore/Encoding and Decoding Errors And Warnings/EitherDecodeNoTypesMatchedErrorExtensions.swift index 1406dffbe..cf5fdfaa9 100644 --- a/Sources/OpenAPIKitCore/Encoding and Decoding Errors And Warnings/EitherDecodeNoTypesMatchedErrorExtensions.swift +++ b/Sources/OpenAPIKitCore/Encoding and Decoding Errors And Warnings/EitherDecodeNoTypesMatchedErrorExtensions.swift @@ -95,7 +95,7 @@ internal extension EitherDecodeNoTypesMatchedError.IndividualFailure { if let decodingError = error.underlyingError as? DecodingError { return decodingError.codingPath } - if let inconsistencyError = error.underlyingError as? InconsistencyError { + if let inconsistencyError = error.underlyingError as? GenericError { return inconsistencyError.codingPath } if let eitherError = error.underlyingError as? EitherDecodeNoTypesMatchedError { diff --git a/Sources/OpenAPIKitCore/Encoding and Decoding Errors And Warnings/InconsistencyError.swift b/Sources/OpenAPIKitCore/Encoding and Decoding Errors And Warnings/GenericError.swift similarity index 88% rename from Sources/OpenAPIKitCore/Encoding and Decoding Errors And Warnings/InconsistencyError.swift rename to Sources/OpenAPIKitCore/Encoding and Decoding Errors And Warnings/GenericError.swift index 6a81f0149..80b829031 100644 --- a/Sources/OpenAPIKitCore/Encoding and Decoding Errors And Warnings/InconsistencyError.swift +++ b/Sources/OpenAPIKitCore/Encoding and Decoding Errors And Warnings/GenericError.swift @@ -1,5 +1,5 @@ // -// InconsistencyError.swift +// GenericError.swift // // // Created by Mathew Polzin on 2/26/20. @@ -8,7 +8,7 @@ /// This error type is thrown when a problem _during_ encoding or decoding but the /// problem is not inherent to the types or structures but rather specific /// to the OpenAPI specification rules. -public struct InconsistencyError: Swift.Error, CustomStringConvertible, OpenAPIError { +public struct GenericError: Swift.Error, CustomStringConvertible, OpenAPIError { public let subjectName: String public let details: String public let codingPath: [CodingKey] diff --git a/Sources/OpenAPIKitCore/Encoding and Decoding Errors And Warnings/RequestDecodingError.swift b/Sources/OpenAPIKitCore/Encoding and Decoding Errors And Warnings/RequestDecodingError.swift index 776bf23fa..1aa633d50 100644 --- a/Sources/OpenAPIKitCore/Encoding and Decoding Errors And Warnings/RequestDecodingError.swift +++ b/Sources/OpenAPIKitCore/Encoding and Decoding Errors And Warnings/RequestDecodingError.swift @@ -11,7 +11,7 @@ extension Error.Decoding { internal let relativeCodingPath: [CodingKey] public enum Context: Sendable { - case inconsistency(InconsistencyError) + case inconsistency(GenericError) case other(Swift.DecodingError) case neither(EitherDecodeNoTypesMatchedError) } @@ -70,7 +70,7 @@ extension Error.Decoding.Request { return Array(path.dropFirst(responsesIndex.advanced(by: 1))) } - public init(_ error: InconsistencyError) { + public init(_ error: GenericError) { context = .inconsistency(error) relativeCodingPath = Self.relativePath(from: error.codingPath) } @@ -95,7 +95,7 @@ extension Error.Decoding.Request: DiggingError { public init(unwrapping error: Swift.DecodingError) { if let decodingError = error.underlyingError as? Swift.DecodingError { self = Self(unwrapping: decodingError) - } else if let inconsistencyError = error.underlyingError as? InconsistencyError { + } else if let inconsistencyError = error.underlyingError as? GenericError { self = Self(inconsistencyError) } else if let eitherError = error.underlyingError as? EitherDecodeNoTypesMatchedError { self = Self(eitherError) diff --git a/Sources/OpenAPIKitCore/Shared/ComponentKey.swift b/Sources/OpenAPIKitCore/Shared/ComponentKey.swift index 454f3f1e5..73120c7ef 100644 --- a/Sources/OpenAPIKitCore/Shared/ComponentKey.swift +++ b/Sources/OpenAPIKitCore/Shared/ComponentKey.swift @@ -51,7 +51,7 @@ extension Shared { public init(from decoder: Decoder) throws { let rawValue = try decoder.singleValueContainer().decode(String.self) guard let key = Self(rawValue: rawValue) else { - throw InconsistencyError( + throw GenericError( subjectName: "Component Key", details: "Keys for components in the Components Object must conform to the regex `^[a-zA-Z0-9\\.\\-_]+$`. '\(rawValue)' does not..", codingPath: decoder.codingPath @@ -66,7 +66,7 @@ extension Shared { // we check for consistency on encode because a string literal // may result in an invalid component key being constructed. guard Self(rawValue: rawValue) != nil else { - throw InconsistencyError( + throw GenericError( subjectName: "Component Key", details: "Keys for components in the Components Object must conform to the regex `^[a-zA-Z0-9\\.\\-_]+$`. '\(rawValue)' does not..", codingPath: container.codingPath diff --git a/Sources/OpenAPIKitCore/Shared/ResponseStatusCode.swift b/Sources/OpenAPIKitCore/Shared/ResponseStatusCode.swift index 82df5365e..aa7731f87 100644 --- a/Sources/OpenAPIKitCore/Shared/ResponseStatusCode.swift +++ b/Sources/OpenAPIKitCore/Shared/ResponseStatusCode.swift @@ -122,7 +122,7 @@ extension Shared.ResponseStatusCode: Decodable { let val = Shared.ResponseStatusCode(rawValue: strVal) guard let value = val else { - throw InconsistencyError( + throw GenericError( subjectName: "status code", details: "Expected the status code to be either an Int, a range like '1XX', or 'default' but found \(strVal) instead", codingPath: decoder.codingPath diff --git a/Sources/OpenAPIKitCore/Utility/Container+DecodeURLAsString.swift b/Sources/OpenAPIKitCore/Utility/Container+DecodeURLAsString.swift index db12e7ed1..44da4a76a 100644 --- a/Sources/OpenAPIKitCore/Utility/Container+DecodeURLAsString.swift +++ b/Sources/OpenAPIKitCore/Utility/Container+DecodeURLAsString.swift @@ -23,7 +23,7 @@ extension KeyedDecodingContainerProtocol { url = URL(string: string) #endif guard let url else { - throw InconsistencyError( + throw GenericError( subjectName: key.stringValue, details: "If specified, must be a valid URL", codingPath: codingPath @@ -50,7 +50,7 @@ extension KeyedDecodingContainerProtocol { url = URL(string: string) #endif guard let url else { - throw InconsistencyError( + throw GenericError( subjectName: key.stringValue, details: "If specified, must be a valid URL", codingPath: codingPath diff --git a/Tests/OpenAPIKit30Tests/Schema Object/SchemaFragmentCombiningTests.swift b/Tests/OpenAPIKit30Tests/Schema Object/SchemaFragmentCombiningTests.swift index 264f9c2a2..d2fc716ea 100644 --- a/Tests/OpenAPIKit30Tests/Schema Object/SchemaFragmentCombiningTests.swift +++ b/Tests/OpenAPIKit30Tests/Schema Object/SchemaFragmentCombiningTests.swift @@ -1010,7 +1010,7 @@ final class SchemaFragmentCombiningTests: XCTestCase { } // MARK: - Inconsistency Failures - func test_generalInconsistencyErrors() { + func test_generalGenericErrors() { let fragmentsArray: [[JSONSchema]] = [ // boolean readOnly/writeOnly, readOnly/readWrite, writeOnly/readWrite @@ -1101,7 +1101,7 @@ final class SchemaFragmentCombiningTests: XCTestCase { } } - func test_integerInconsistencyErrors() { + func test_integerGenericErrors() { let minBelowZero = [ JSONSchema.IntegerContext(minimum: (-1, exclusive: false)) @@ -1128,7 +1128,7 @@ final class SchemaFragmentCombiningTests: XCTestCase { } } - func test_numberInconsistencyErrors() { + func test_numberGenericErrors() { let minBelowZero = [ JSONSchema.NumericContext(minimum: (-1, exclusive: false)) @@ -1155,7 +1155,7 @@ final class SchemaFragmentCombiningTests: XCTestCase { } } - func test_stringInconsistencyErrors() { + func test_stringGenericErrors() { let minBelowZero = [ JSONSchema.StringContext(minLength: -1) @@ -1182,7 +1182,7 @@ final class SchemaFragmentCombiningTests: XCTestCase { } } - func test_arrayInconsistencyErrors() { + func test_arrayGenericErrors() { let minBelowZero = [ JSONSchema.ArrayContext(minItems: -1) @@ -1209,7 +1209,7 @@ final class SchemaFragmentCombiningTests: XCTestCase { } } - func test_objectInconsistencyErrors() { + func test_objectGenericErrors() { let minBelowZero = [ JSONSchema.ObjectContext(properties: [:], minProperties: -1) diff --git a/Tests/OpenAPIKitCoreTests/InconsistencyErrorTests.swift b/Tests/OpenAPIKitCoreTests/GenericErrorTests.swift similarity index 76% rename from Tests/OpenAPIKitCoreTests/InconsistencyErrorTests.swift rename to Tests/OpenAPIKitCoreTests/GenericErrorTests.swift index fcbe8ae3b..3c38939ff 100644 --- a/Tests/OpenAPIKitCoreTests/InconsistencyErrorTests.swift +++ b/Tests/OpenAPIKitCoreTests/GenericErrorTests.swift @@ -1,5 +1,5 @@ // -// InconsistencyErrorTests.swift +// GenericErrorTests.swift // // // Created by Mathew Polzin on 7/2/20. @@ -8,8 +8,8 @@ @testable import OpenAPIKitCore import XCTest -final class InconsistencyErrorTests: XCTestCase { - let error = InconsistencyError( +final class GenericErrorTests: XCTestCase { + let error = GenericError( subjectName: "subject", details: "details", codingPath: [] diff --git a/Tests/OpenAPIKitTests/Schema Object/SchemaFragmentCombiningTests.swift b/Tests/OpenAPIKitTests/Schema Object/SchemaFragmentCombiningTests.swift index ba91a0e78..c6cc5cf6a 100644 --- a/Tests/OpenAPIKitTests/Schema Object/SchemaFragmentCombiningTests.swift +++ b/Tests/OpenAPIKitTests/Schema Object/SchemaFragmentCombiningTests.swift @@ -1075,7 +1075,7 @@ final class SchemaFragmentCombiningTests: XCTestCase { } // MARK: - Inconsistency Failures - func test_generalInconsistencyErrors() { + func test_generalGenericErrors() { let fragmentsArray: [[JSONSchema]] = [ // boolean readOnly/writeOnly, readOnly/readWrite, writeOnly/readWrite @@ -1166,7 +1166,7 @@ final class SchemaFragmentCombiningTests: XCTestCase { } } - func test_integerInconsistencyErrors() { + func test_integerGenericErrors() { let minBelowZero = [ JSONSchema.IntegerContext(minimum: (-1, exclusive: false)) @@ -1193,7 +1193,7 @@ final class SchemaFragmentCombiningTests: XCTestCase { } } - func test_numberInconsistencyErrors() { + func test_numberGenericErrors() { let minBelowZero = [ JSONSchema.NumericContext(minimum: (-1, exclusive: false)) @@ -1220,7 +1220,7 @@ final class SchemaFragmentCombiningTests: XCTestCase { } } - func test_stringInconsistencyErrors() { + func test_stringGenericErrors() { let minBelowZero = [ JSONSchema.StringContext(minLength: -1) @@ -1247,7 +1247,7 @@ final class SchemaFragmentCombiningTests: XCTestCase { } } - func test_arrayInconsistencyErrors() { + func test_arrayGenericErrors() { let minBelowZero = [ JSONSchema.ArrayContext(minItems: -1) @@ -1274,7 +1274,7 @@ final class SchemaFragmentCombiningTests: XCTestCase { } } - func test_objectInconsistencyErrors() { + func test_objectGenericErrors() { let minBelowZero = [ JSONSchema.ObjectContext(properties: [:], minProperties: -1) From 118decafba8e51c2b9873a15e423f94fdb352e29 Mon Sep 17 00:00:00 2001 From: Mathew Polzin Date: Mon, 12 May 2025 22:07:25 -0500 Subject: [PATCH 2/3] update error message for generic error --- .../OpenAPIDecodingErrors.swift | 2 +- .../ComponentErrorTests.swift | 4 ++-- .../DocumentErrorTests.swift | 2 +- .../JSONReferenceErrorTests.swift | 2 +- .../PathsErrorTests.swift | 8 ++++---- .../RequestContentMapErrorTests.swift | 2 +- .../ResponseErrorTests.swift | 4 ++-- .../SchemaErrorTests.swift | 2 +- .../SecuritySchemeErrorTests.swift | 4 ++-- .../Document/DocumentInfoTests.swift | 2 +- Tests/OpenAPIKit30Tests/Document/DocumentTests.swift | 2 +- .../ExternalDocumentationTests.swift | 2 +- .../Schema Object/JSONSchemaTests.swift | 4 ++-- .../Schema Object/SchemaFragmentTests.swift | 8 ++++---- .../Schema Object/SchemaObjectYamsTests.swift | 4 ++-- .../OpenAPIKit30Tests/Validator/ValidatorTests.swift | 4 ++-- .../ComponentErrorTests.swift | 4 ++-- .../DocumentErrorTests.swift | 2 +- .../JSONReferenceErrorTests.swift | 2 +- .../PathsErrorTests.swift | 12 ++++++------ .../RequestContentMapErrorTests.swift | 2 +- .../ResponseErrorTests.swift | 4 ++-- .../SchemaErrorTests.swift | 4 ++-- .../SecuritySchemeErrorTests.swift | 4 ++-- .../OpenAPIKitTests/Document/DocumentInfoTests.swift | 2 +- Tests/OpenAPIKitTests/Document/DocumentTests.swift | 2 +- .../OpenAPIKitTests/ExternalDocumentationTests.swift | 2 +- .../Schema Object/JSONSchemaTests.swift | 4 ++-- .../Schema Object/SchemaFragmentTests.swift | 8 ++++---- .../Schema Object/SchemaObjectYamsTests.swift | 4 ++-- Tests/OpenAPIKitTests/Validator/ValidatorTests.swift | 4 ++-- 31 files changed, 58 insertions(+), 58 deletions(-) diff --git a/Sources/OpenAPIKitCore/Encoding and Decoding Errors And Warnings/OpenAPIDecodingErrors.swift b/Sources/OpenAPIKitCore/Encoding and Decoding Errors And Warnings/OpenAPIDecodingErrors.swift index 9861837e7..4111ab04c 100644 --- a/Sources/OpenAPIKitCore/Encoding and Decoding Errors And Warnings/OpenAPIDecodingErrors.swift +++ b/Sources/OpenAPIKitCore/Encoding and Decoding Errors And Warnings/OpenAPIDecodingErrors.swift @@ -90,7 +90,7 @@ public extension OpenAPIError { case .dataCorrupted: return "Could not parse `\(subjectName)`" case .inconsistency(details: _): - return "Inconsistency encountered when parsing `\(subjectName)`" + return "Problem encountered when parsing `\(subjectName)`" } }() diff --git a/Tests/OpenAPIKit30ErrorReportingTests/ComponentErrorTests.swift b/Tests/OpenAPIKit30ErrorReportingTests/ComponentErrorTests.swift index 53f247b55..14ca00492 100644 --- a/Tests/OpenAPIKit30ErrorReportingTests/ComponentErrorTests.swift +++ b/Tests/OpenAPIKit30ErrorReportingTests/ComponentErrorTests.swift @@ -30,7 +30,7 @@ final class ComponentErrorTests: XCTestCase { let openAPIError = OpenAPI.Error(from: error) - XCTAssertEqual(openAPIError.localizedDescription, #"Inconsistency encountered when parsing `h#llo` in Document.components.schemas: Keys for components in the Components Object must conform to the regex `^[a-zA-Z0-9\.\-_]+$`. 'h#llo' does not..."#) + XCTAssertEqual(openAPIError.localizedDescription, #"Problem encountered when parsing `h#llo` in Document.components.schemas: Keys for components in the Components Object must conform to the regex `^[a-zA-Z0-9\.\-_]+$`. 'h#llo' does not..."#) XCTAssertEqual(openAPIError.codingPath.map { $0.stringValue }, ["components", "schemas", "h#llo"]) } } @@ -57,7 +57,7 @@ final class ComponentErrorTests: XCTestCase { let openAPIError = OpenAPI.Error(from: error) - XCTAssertEqual(openAPIError.localizedDescription, "Found neither a $ref nor a Header. \n\nHeader could not be decoded because:\nInconsistency encountered when parsing `Header`: A header parameter must specify either `content` or `schema`..") + XCTAssertEqual(openAPIError.localizedDescription, "Found neither a $ref nor a Header. \n\nHeader could not be decoded because:\nProblem encountered when parsing `Header`: A header parameter must specify either `content` or `schema`..") XCTAssertEqual(openAPIError.codingPath.map { $0.stringValue }, ["components", "responses", "IllFormed", "headers", "MissingSchemaKey"]) } } diff --git a/Tests/OpenAPIKit30ErrorReportingTests/DocumentErrorTests.swift b/Tests/OpenAPIKit30ErrorReportingTests/DocumentErrorTests.swift index 30cedeff6..1840cee13 100644 --- a/Tests/OpenAPIKit30ErrorReportingTests/DocumentErrorTests.swift +++ b/Tests/OpenAPIKit30ErrorReportingTests/DocumentErrorTests.swift @@ -45,7 +45,7 @@ final class DocumentErrorTests: XCTestCase { let openAPIError = OpenAPI.Error(from: error) - XCTAssertEqual(openAPIError.localizedDescription, "Inconsistency encountered when parsing `openapi` in the root Document object: Cannot initialize Version from invalid String value null.") + XCTAssertEqual(openAPIError.localizedDescription, "Problem encountered when parsing `openapi` in the root Document object: Cannot initialize Version from invalid String value null.") XCTAssertEqual(openAPIError.codingPath.map { $0.stringValue }, [ "openapi" ]) diff --git a/Tests/OpenAPIKit30ErrorReportingTests/JSONReferenceErrorTests.swift b/Tests/OpenAPIKit30ErrorReportingTests/JSONReferenceErrorTests.swift index e6acb4d05..143f88c9d 100644 --- a/Tests/OpenAPIKit30ErrorReportingTests/JSONReferenceErrorTests.swift +++ b/Tests/OpenAPIKit30ErrorReportingTests/JSONReferenceErrorTests.swift @@ -30,7 +30,7 @@ final class JSONReferenceErrorTests: XCTestCase { let openAPIError = OpenAPI.Error(from: error) - XCTAssertEqual(openAPIError.localizedDescription, "Found neither a $ref nor a Parameter in .parameters[0] for the **GET** endpoint under `/hello/world`. \n\nJSONReference could not be decoded because:\nInconsistency encountered when parsing `JSON Reference`: Failed to parse a valid URI for a JSON Reference from 'not a reference'.\n\nParameter could not be decoded because:\nExpected to find `name` key but it is missing..") + XCTAssertEqual(openAPIError.localizedDescription, "Found neither a $ref nor a Parameter in .parameters[0] for the **GET** endpoint under `/hello/world`. \n\nJSONReference could not be decoded because:\nProblem encountered when parsing `JSON Reference`: Failed to parse a valid URI for a JSON Reference from 'not a reference'.\n\nParameter could not be decoded because:\nExpected to find `name` key but it is missing..") XCTAssertEqual(openAPIError.codingPath.map { $0.stringValue }, [ "paths", "/hello/world", diff --git a/Tests/OpenAPIKit30ErrorReportingTests/PathsErrorTests.swift b/Tests/OpenAPIKit30ErrorReportingTests/PathsErrorTests.swift index bba441e24..c908d839c 100644 --- a/Tests/OpenAPIKit30ErrorReportingTests/PathsErrorTests.swift +++ b/Tests/OpenAPIKit30ErrorReportingTests/PathsErrorTests.swift @@ -104,7 +104,7 @@ final class PathsErrorTests: XCTestCase { let openAPIError = OpenAPI.Error(from: error) - XCTAssertEqual(openAPIError.localizedDescription, "Found neither a $ref nor a Parameter in .parameters[0] under the `/hello/world` path. \n\nParameter could not be decoded because:\nInconsistency encountered when parsing `world`: positional path parameters must be explicitly set to required.." + XCTAssertEqual(openAPIError.localizedDescription, "Found neither a $ref nor a Parameter in .parameters[0] under the `/hello/world` path. \n\nParameter could not be decoded because:\nProblem encountered when parsing `world`: positional path parameters must be explicitly set to required.." ) XCTAssertEqual( openAPIError.codingPath.map { $0.stringValue }, @@ -137,7 +137,7 @@ final class PathsErrorTests: XCTestCase { let openAPIError = OpenAPI.Error(from: error) - XCTAssertEqual(openAPIError.localizedDescription, "Found neither a $ref nor a Parameter in .parameters[0] under the `/hello/world` path. \n\nParameter could not be decoded because:\nInconsistency encountered when parsing `world`: A parameter must specify either `content` or `schema`.." + XCTAssertEqual(openAPIError.localizedDescription, "Found neither a $ref nor a Parameter in .parameters[0] under the `/hello/world` path. \n\nParameter could not be decoded because:\nProblem encountered when parsing `world`: A parameter must specify either `content` or `schema`.." ) XCTAssertEqual( openAPIError.codingPath.map { $0.stringValue }, @@ -176,7 +176,7 @@ final class PathsErrorTests: XCTestCase { let openAPIError = OpenAPI.Error(from: error) - XCTAssertEqual(openAPIError.localizedDescription, "Found neither a $ref nor a Parameter in .parameters[0] under the `/hello/world` path. \n\nParameter could not be decoded because:\nInconsistency encountered when parsing `world`: A parameter must specify one but not both `content` and `schema`.." + XCTAssertEqual(openAPIError.localizedDescription, "Found neither a $ref nor a Parameter in .parameters[0] under the `/hello/world` path. \n\nParameter could not be decoded because:\nProblem encountered when parsing `world`: A parameter must specify one but not both `content` and `schema`.." ) XCTAssertEqual( openAPIError.codingPath.map { $0.stringValue }, @@ -219,7 +219,7 @@ final class PathsErrorTests: XCTestCase { XCTAssertEqual( openAPIError?.localizedDescription, """ - Inconsistency encountered when parsing `OpenAPI Schema`: Found schema attributes not consistent with the type specified: object. Specifically, attributes for these other types: [\"array\"]. + Problem encountered when parsing `OpenAPI Schema`: Found schema attributes not consistent with the type specified: object. Specifically, attributes for these other types: [\"array\"]. """ ) XCTAssertEqual( diff --git a/Tests/OpenAPIKit30ErrorReportingTests/RequestContentMapErrorTests.swift b/Tests/OpenAPIKit30ErrorReportingTests/RequestContentMapErrorTests.swift index 75ac121c0..4c353ce09 100644 --- a/Tests/OpenAPIKit30ErrorReportingTests/RequestContentMapErrorTests.swift +++ b/Tests/OpenAPIKit30ErrorReportingTests/RequestContentMapErrorTests.swift @@ -107,7 +107,7 @@ final class RequestContentMapErrorTests: XCTestCase { let openAPIError = OpenAPI.Error(from: error) - XCTAssertEqual(openAPIError.localizedDescription, "Inconsistency encountered when parsing `Vendor Extension` in .content['application/json'] for the request body of the **GET** endpoint under `/hello/world`: Found at least one vendor extension property that does not begin with the required 'x-' prefix. Invalid properties: [ invalid ].") + XCTAssertEqual(openAPIError.localizedDescription, "Problem encountered when parsing `Vendor Extension` in .content['application/json'] for the request body of the **GET** endpoint under `/hello/world`: Found at least one vendor extension property that does not begin with the required 'x-' prefix. Invalid properties: [ invalid ].") XCTAssertEqual(openAPIError.codingPath.map { $0.stringValue }, [ "paths", "/hello/world", diff --git a/Tests/OpenAPIKit30ErrorReportingTests/ResponseErrorTests.swift b/Tests/OpenAPIKit30ErrorReportingTests/ResponseErrorTests.swift index 2d7552afd..5077fb7c3 100644 --- a/Tests/OpenAPIKit30ErrorReportingTests/ResponseErrorTests.swift +++ b/Tests/OpenAPIKit30ErrorReportingTests/ResponseErrorTests.swift @@ -39,7 +39,7 @@ final class ResponseErrorTests: XCTestCase { let openAPIError = OpenAPI.Error(from: error) - XCTAssertEqual(openAPIError.localizedDescription, "Found neither a $ref nor a Header in .headers.hi for the status code '200' response of the **GET** endpoint under `/hello/world`. \n\nHeader could not be decoded because:\nInconsistency encountered when parsing `Header`: A header must specify one but not both `content` and `schema`..") + XCTAssertEqual(openAPIError.localizedDescription, "Found neither a $ref nor a Header in .headers.hi for the status code '200' response of the **GET** endpoint under `/hello/world`. \n\nHeader could not be decoded because:\nProblem encountered when parsing `Header`: A header must specify one but not both `content` and `schema`..") XCTAssertEqual(openAPIError.codingPath.map { $0.stringValue }, [ "paths", "/hello/world", @@ -102,7 +102,7 @@ final class ResponseErrorTests: XCTestCase { let openAPIError = OpenAPI.Error(from: error) - XCTAssertEqual(openAPIError.localizedDescription, "Found neither a $ref nor a Response in .responses.200 for the **GET** endpoint under `/hello/world`. \n\nResponse could not be decoded because:\nInconsistency encountered when parsing `Vendor Extension`: Found at least one vendor extension property that does not begin with the required 'x-' prefix. Invalid properties: [ not-a-thing ]..") + XCTAssertEqual(openAPIError.localizedDescription, "Found neither a $ref nor a Response in .responses.200 for the **GET** endpoint under `/hello/world`. \n\nResponse could not be decoded because:\nProblem encountered when parsing `Vendor Extension`: Found at least one vendor extension property that does not begin with the required 'x-' prefix. Invalid properties: [ not-a-thing ]..") XCTAssertEqual(openAPIError.codingPath.map { $0.stringValue }, [ "paths", "/hello/world", diff --git a/Tests/OpenAPIKit30ErrorReportingTests/SchemaErrorTests.swift b/Tests/OpenAPIKit30ErrorReportingTests/SchemaErrorTests.swift index 3667ed4fc..be372a3b8 100644 --- a/Tests/OpenAPIKit30ErrorReportingTests/SchemaErrorTests.swift +++ b/Tests/OpenAPIKit30ErrorReportingTests/SchemaErrorTests.swift @@ -35,7 +35,7 @@ final class SchemaErrorTests: XCTestCase { let openAPIError = OpenAPI.Error(from: error) - XCTAssertEqual(openAPIError.localizedDescription, "Found neither a $ref nor a JSONSchema in .content['application/json'].schema for the status code '200' response of the **GET** endpoint under `/hello/world`. \n\nJSONSchema could not be decoded because:\nInconsistency encountered when parsing `maximum`: Expected an Integer literal but found a floating point value (1.234)..") + XCTAssertEqual(openAPIError.localizedDescription, "Found neither a $ref nor a JSONSchema in .content['application/json'].schema for the status code '200' response of the **GET** endpoint under `/hello/world`. \n\nJSONSchema could not be decoded because:\nProblem encountered when parsing `maximum`: Expected an Integer literal but found a floating point value (1.234)..") XCTAssertEqual(openAPIError.codingPath.map { $0.stringValue }, [ "paths", "/hello/world", diff --git a/Tests/OpenAPIKit30ErrorReportingTests/SecuritySchemeErrorTests.swift b/Tests/OpenAPIKit30ErrorReportingTests/SecuritySchemeErrorTests.swift index ab03977fc..3728c098c 100644 --- a/Tests/OpenAPIKit30ErrorReportingTests/SecuritySchemeErrorTests.swift +++ b/Tests/OpenAPIKit30ErrorReportingTests/SecuritySchemeErrorTests.swift @@ -29,7 +29,7 @@ final class SecuritySchemeErrorTests: XCTestCase { let openAPIError = OpenAPI.Error(from: error) - XCTAssertEqual(openAPIError.localizedDescription, "Inconsistency encountered when parsing `security` in the root Document object: Each key found in a Security Requirement dictionary must refer to a Security Scheme present in the Components dictionary.") + XCTAssertEqual(openAPIError.localizedDescription, "Problem encountered when parsing `security` in the root Document object: Each key found in a Security Requirement dictionary must refer to a Security Scheme present in the Components dictionary.") XCTAssertEqual(openAPIError.codingPath.map { $0.stringValue }, [ "security" ]) @@ -61,7 +61,7 @@ final class SecuritySchemeErrorTests: XCTestCase { let openAPIError = OpenAPI.Error(from: error) - XCTAssertEqual(openAPIError.localizedDescription, "Inconsistency encountered when parsing `hello` in Document.paths['/hello/world'].get.security: Each key found in a Security Requirement dictionary must refer to a Security Scheme present in the Components dictionary.") + XCTAssertEqual(openAPIError.localizedDescription, "Problem encountered when parsing `hello` in Document.paths['/hello/world'].get.security: Each key found in a Security Requirement dictionary must refer to a Security Scheme present in the Components dictionary.") XCTAssertEqual(openAPIError.codingPath.map { $0.stringValue }, [ "paths", "/hello/world", diff --git a/Tests/OpenAPIKit30Tests/Document/DocumentInfoTests.swift b/Tests/OpenAPIKit30Tests/Document/DocumentInfoTests.swift index 9533de090..f600bd117 100644 --- a/Tests/OpenAPIKit30Tests/Document/DocumentInfoTests.swift +++ b/Tests/OpenAPIKit30Tests/Document/DocumentInfoTests.swift @@ -407,7 +407,7 @@ extension DocumentInfoTests { } """.data(using: .utf8)! XCTAssertThrowsError( try orderUnstableDecode(OpenAPI.Document.Info.self, from: infoData)) { error in - XCTAssertEqual(OpenAPI.Error(from: error).localizedDescription, "Inconsistency encountered when parsing `termsOfService`: If specified, must be a valid URL.") + XCTAssertEqual(OpenAPI.Error(from: error).localizedDescription, "Problem encountered when parsing `termsOfService`: If specified, must be a valid URL.") } } diff --git a/Tests/OpenAPIKit30Tests/Document/DocumentTests.swift b/Tests/OpenAPIKit30Tests/Document/DocumentTests.swift index 53a890bd7..761b7f398 100644 --- a/Tests/OpenAPIKit30Tests/Document/DocumentTests.swift +++ b/Tests/OpenAPIKit30Tests/Document/DocumentTests.swift @@ -580,7 +580,7 @@ extension DocumentTests { } } """.data(using: .utf8)! - XCTAssertThrowsError(try orderUnstableDecode(OpenAPI.Document.self, from: documentData)) { error in XCTAssertEqual(OpenAPI.Error(from: error).localizedDescription, "Inconsistency encountered when parsing `openapi` in the root Document object: Cannot initialize Version from invalid String value 3.0.9.") } + XCTAssertThrowsError(try orderUnstableDecode(OpenAPI.Document.self, from: documentData)) { error in XCTAssertEqual(OpenAPI.Error(from: error).localizedDescription, "Problem encountered when parsing `openapi` in the root Document object: Cannot initialize Version from invalid String value 3.0.9.") } } func test_specifyServers_encode() throws { diff --git a/Tests/OpenAPIKit30Tests/ExternalDocumentationTests.swift b/Tests/OpenAPIKit30Tests/ExternalDocumentationTests.swift index 97a8c2788..3a1bd21e4 100644 --- a/Tests/OpenAPIKit30Tests/ExternalDocumentationTests.swift +++ b/Tests/OpenAPIKit30Tests/ExternalDocumentationTests.swift @@ -140,7 +140,7 @@ extension ExternalDocumentationTests { """.data(using: .utf8)! XCTAssertThrowsError(try orderUnstableDecode(OpenAPI.ExternalDocumentation.self, from: externalDocsData)) { error in - XCTAssertEqual(OpenAPI.Error(from: error).localizedDescription, "Inconsistency encountered when parsing `url`: If specified, must be a valid URL.") + XCTAssertEqual(OpenAPI.Error(from: error).localizedDescription, "Problem encountered when parsing `url`: If specified, must be a valid URL.") } } } diff --git a/Tests/OpenAPIKit30Tests/Schema Object/JSONSchemaTests.swift b/Tests/OpenAPIKit30Tests/Schema Object/JSONSchemaTests.swift index 8d5319e63..3e7722440 100644 --- a/Tests/OpenAPIKit30Tests/Schema Object/JSONSchemaTests.swift +++ b/Tests/OpenAPIKit30Tests/Schema Object/JSONSchemaTests.swift @@ -1350,7 +1350,7 @@ extension SchemaObjectTests { XCTAssertEqual(warnResult.warnings.count, 1) // NOTE: not the most informative warnings, would like to do better. - XCTAssertEqual(warnResult.warnings.first?.localizedDescription, "Inconsistency encountered when parsing `OpenAPI Schema`: Found nothing but unsupported attributes..") + XCTAssertEqual(warnResult.warnings.first?.localizedDescription, "Problem encountered when parsing `OpenAPI Schema`: Found nothing but unsupported attributes..") // we are actually at the root path in this test case so the // following should be an empty string! XCTAssertEqual(warnResult.warnings.first?.codingPathString, "") @@ -1409,7 +1409,7 @@ extension SchemaObjectTests { let warnResult = try orderUnstableDecode(JSONSchema.self, from: badSchema) XCTAssertEqual(warnResult.warnings.count, 1) - XCTAssertEqual(warnResult.warnings.first?.localizedDescription, "Inconsistency encountered when parsing `OpenAPI Schema`: Found schema attributes not consistent with the type specified: object. Specifically, attributes for these other types: [\"array\"].") + XCTAssertEqual(warnResult.warnings.first?.localizedDescription, "Problem encountered when parsing `OpenAPI Schema`: Found schema attributes not consistent with the type specified: object. Specifically, attributes for these other types: [\"array\"].") // we are actually at the root path in this test case so the // following should be an empty string! XCTAssertEqual(warnResult.warnings.first?.codingPathString, "") diff --git a/Tests/OpenAPIKit30Tests/Schema Object/SchemaFragmentTests.swift b/Tests/OpenAPIKit30Tests/Schema Object/SchemaFragmentTests.swift index c4fc0b1ec..13e4691a3 100644 --- a/Tests/OpenAPIKit30Tests/Schema Object/SchemaFragmentTests.swift +++ b/Tests/OpenAPIKit30Tests/Schema Object/SchemaFragmentTests.swift @@ -160,7 +160,7 @@ extension SchemaFragmentTests { let warnResult = try orderUnstableDecode(JSONSchema.self, from: t) XCTAssertEqual(warnResult.warnings.count, 1) - XCTAssertEqual(warnResult.warnings.first?.localizedDescription, "Inconsistency encountered when parsing `Schema`: A schema contains properties for multiple types of schemas, namely: [\"array\", \"object\"]..") + XCTAssertEqual(warnResult.warnings.first?.localizedDescription, "Problem encountered when parsing `Schema`: A schema contains properties for multiple types of schemas, namely: [\"array\", \"object\"]..") // we are actually at the root path in this test case so the // following should be an empty string! XCTAssertEqual(warnResult.warnings.first?.codingPathString, "") @@ -182,7 +182,7 @@ extension SchemaFragmentTests { let warnResult = try orderUnstableDecode(JSONSchema.self, from: t) XCTAssertEqual(warnResult.warnings.count, 1) - XCTAssertEqual(warnResult.warnings.first?.localizedDescription, "Inconsistency encountered when parsing `OpenAPI Schema`: Found schema attributes not consistent with the type specified: object. Specifically, attributes for these other types: [\"array\"].") + XCTAssertEqual(warnResult.warnings.first?.localizedDescription, "Problem encountered when parsing `OpenAPI Schema`: Found schema attributes not consistent with the type specified: object. Specifically, attributes for these other types: [\"array\"].") // we are actually at the root path in this test case so the // following should be an empty string! XCTAssertEqual(warnResult.warnings.first?.codingPathString, "") @@ -225,7 +225,7 @@ extension SchemaFragmentTests { XCTAssertEqual(warnResult1.warnings.count, 1) // NOTE: Not a very informative warning, would like to do better. - XCTAssertEqual(warnResult1.warnings.first?.localizedDescription, "Inconsistency encountered when parsing `OpenAPI Schema`: Found nothing but unsupported attributes..") + XCTAssertEqual(warnResult1.warnings.first?.localizedDescription, "Problem encountered when parsing `OpenAPI Schema`: Found nothing but unsupported attributes..") // we are actually at the root path in this test case so the // following should be an empty string! XCTAssertEqual(warnResult1.warnings.first?.codingPathString, "") @@ -234,7 +234,7 @@ extension SchemaFragmentTests { XCTAssertEqual(warnResult2.warnings.count, 1) // NOTE: Not a very informative warning, would like to do better. - XCTAssertEqual(warnResult2.warnings.first?.localizedDescription, "Inconsistency encountered when parsing `OpenAPI Schema`: Found nothing but unsupported attributes..") + XCTAssertEqual(warnResult2.warnings.first?.localizedDescription, "Problem encountered when parsing `OpenAPI Schema`: Found nothing but unsupported attributes..") // we are actually at the root path in this test case so the // following should be an empty string! XCTAssertEqual(warnResult2.warnings.first?.codingPathString, "") diff --git a/Tests/OpenAPIKit30Tests/Schema Object/SchemaObjectYamsTests.swift b/Tests/OpenAPIKit30Tests/Schema Object/SchemaObjectYamsTests.swift index b191ea907..c892dab9d 100644 --- a/Tests/OpenAPIKit30Tests/Schema Object/SchemaObjectYamsTests.swift +++ b/Tests/OpenAPIKit30Tests/Schema Object/SchemaObjectYamsTests.swift @@ -40,7 +40,7 @@ final class SchemaObjectYamsTests: XCTestCase { """ XCTAssertThrowsError(try YAMLDecoder().decode(JSONSchema.self, from: integerString)) { error in - XCTAssertEqual(OpenAPI.Error(from: error).localizedDescription, "Inconsistency encountered when parsing `maximum`: Expected an Integer literal but found a floating point value (10.2).") + XCTAssertEqual(OpenAPI.Error(from: error).localizedDescription, "Problem encountered when parsing `maximum`: Expected an Integer literal but found a floating point value (10.2).") } let integerString2 = @@ -50,7 +50,7 @@ final class SchemaObjectYamsTests: XCTestCase { """ XCTAssertThrowsError(try YAMLDecoder().decode(JSONSchema.self, from: integerString2)) { error in - XCTAssertEqual(OpenAPI.Error(from: error).localizedDescription, "Inconsistency encountered when parsing `minimum`: Expected an Integer literal but found a floating point value (1.1).") + XCTAssertEqual(OpenAPI.Error(from: error).localizedDescription, "Problem encountered when parsing `minimum`: Expected an Integer literal but found a floating point value (1.1).") } } } diff --git a/Tests/OpenAPIKit30Tests/Validator/ValidatorTests.swift b/Tests/OpenAPIKit30Tests/Validator/ValidatorTests.swift index c96acc1cf..d8e3730af 100644 --- a/Tests/OpenAPIKit30Tests/Validator/ValidatorTests.swift +++ b/Tests/OpenAPIKit30Tests/Validator/ValidatorTests.swift @@ -1441,7 +1441,7 @@ final class ValidatorTests: XCTestCase { XCTAssertEqual(warnings.count, 1) XCTAssertEqual( warnings.first?.localizedDescription, - "Inconsistency encountered when parsing ``: \'gzip\' could not be parsed as a Content Type. Content Types should have the format \'/\'." + "Problem encountered when parsing ``: \'gzip\' could not be parsed as a Content Type. Content Types should have the format \'/\'." ) XCTAssertEqual(warnings.first?.codingPathString, ".paths[\'/test\'].get.responses.200.content") XCTAssertNotNil(warnings.first?.underlyingError) @@ -1486,7 +1486,7 @@ final class ValidatorTests: XCTestCase { XCTAssertEqual(errors?.values.count, 1) XCTAssertEqual( errors?.localizedDescription, - "Inconsistency encountered when parsing ``: \'gzip\' could not be parsed as a Content Type. Content Types should have the format \'/\'. at path: .paths[\'/test\'].get.responses.200.content" + "Problem encountered when parsing ``: \'gzip\' could not be parsed as a Content Type. Content Types should have the format \'/\'. at path: .paths[\'/test\'].get.responses.200.content" ) XCTAssertEqual(errors?.values.first?.codingPathString, ".paths[\'/test\'].get.responses.200.content") } diff --git a/Tests/OpenAPIKitErrorReportingTests/ComponentErrorTests.swift b/Tests/OpenAPIKitErrorReportingTests/ComponentErrorTests.swift index 60e010320..76ed176f3 100644 --- a/Tests/OpenAPIKitErrorReportingTests/ComponentErrorTests.swift +++ b/Tests/OpenAPIKitErrorReportingTests/ComponentErrorTests.swift @@ -30,7 +30,7 @@ final class ComponentErrorTests: XCTestCase { let openAPIError = OpenAPI.Error(from: error) - XCTAssertEqual(openAPIError.localizedDescription, #"Inconsistency encountered when parsing `h#llo` in Document.components.schemas: Keys for components in the Components Object must conform to the regex `^[a-zA-Z0-9\.\-_]+$`. 'h#llo' does not..."#) + XCTAssertEqual(openAPIError.localizedDescription, #"Problem encountered when parsing `h#llo` in Document.components.schemas: Keys for components in the Components Object must conform to the regex `^[a-zA-Z0-9\.\-_]+$`. 'h#llo' does not..."#) XCTAssertEqual(openAPIError.codingPath.map { $0.stringValue }, ["components", "schemas", "h#llo"]) } } @@ -57,7 +57,7 @@ final class ComponentErrorTests: XCTestCase { let openAPIError = OpenAPI.Error(from: error) - XCTAssertEqual(openAPIError.localizedDescription, "Found neither a $ref nor a Header. \n\nHeader could not be decoded because:\nInconsistency encountered when parsing `Header`: A header parameter must specify either `content` or `schema`..") + XCTAssertEqual(openAPIError.localizedDescription, "Found neither a $ref nor a Header. \n\nHeader could not be decoded because:\nProblem encountered when parsing `Header`: A header parameter must specify either `content` or `schema`..") XCTAssertEqual(openAPIError.codingPath.map { $0.stringValue }, ["components", "responses", "IllFormed", "headers", "MissingSchemaKey"]) } } diff --git a/Tests/OpenAPIKitErrorReportingTests/DocumentErrorTests.swift b/Tests/OpenAPIKitErrorReportingTests/DocumentErrorTests.swift index 9d3a03d26..2a5bc2d52 100644 --- a/Tests/OpenAPIKitErrorReportingTests/DocumentErrorTests.swift +++ b/Tests/OpenAPIKitErrorReportingTests/DocumentErrorTests.swift @@ -44,7 +44,7 @@ final class DocumentErrorTests: XCTestCase { let openAPIError = OpenAPI.Error(from: error) - XCTAssertEqual(openAPIError.localizedDescription, "Inconsistency encountered when parsing `openapi` in the root Document object: Cannot initialize Version from invalid String value null.") + XCTAssertEqual(openAPIError.localizedDescription, "Problem encountered when parsing `openapi` in the root Document object: Cannot initialize Version from invalid String value null.") XCTAssertEqual(openAPIError.codingPath.map { $0.stringValue }, [ "openapi" ]) diff --git a/Tests/OpenAPIKitErrorReportingTests/JSONReferenceErrorTests.swift b/Tests/OpenAPIKitErrorReportingTests/JSONReferenceErrorTests.swift index 66167bd49..bfdbe0e12 100644 --- a/Tests/OpenAPIKitErrorReportingTests/JSONReferenceErrorTests.swift +++ b/Tests/OpenAPIKitErrorReportingTests/JSONReferenceErrorTests.swift @@ -30,7 +30,7 @@ final class JSONReferenceErrorTests: XCTestCase { let openAPIError = OpenAPI.Error(from: error) - XCTAssertEqual(openAPIError.localizedDescription, "Found neither a $ref nor a Parameter in .parameters[0] for the **GET** endpoint under `/hello/world`. \n\nReference could not be decoded because:\nInconsistency encountered when parsing `JSON Reference`: Failed to parse a valid URI for a JSON Reference from 'not a reference'.\n\nParameter could not be decoded because:\nExpected to find `name` key but it is missing..") + XCTAssertEqual(openAPIError.localizedDescription, "Found neither a $ref nor a Parameter in .parameters[0] for the **GET** endpoint under `/hello/world`. \n\nReference could not be decoded because:\nProblem encountered when parsing `JSON Reference`: Failed to parse a valid URI for a JSON Reference from 'not a reference'.\n\nParameter could not be decoded because:\nExpected to find `name` key but it is missing..") XCTAssertEqual(openAPIError.codingPath.map { $0.stringValue }, [ "paths", "/hello/world", diff --git a/Tests/OpenAPIKitErrorReportingTests/PathsErrorTests.swift b/Tests/OpenAPIKitErrorReportingTests/PathsErrorTests.swift index e5dd3b760..e685b5545 100644 --- a/Tests/OpenAPIKitErrorReportingTests/PathsErrorTests.swift +++ b/Tests/OpenAPIKitErrorReportingTests/PathsErrorTests.swift @@ -27,7 +27,7 @@ final class PathsErrorTests: XCTestCase { let openAPIError = OpenAPI.Error(from: error) - XCTAssertEqual(openAPIError.localizedDescription, "Found neither a $ref nor a PathItem in Document.paths['/hello/world']. \n\nReference could not be decoded because:\nInconsistency encountered when parsing `$ref`: Expected a reference string, but found an empty string instead..." + XCTAssertEqual(openAPIError.localizedDescription, "Found neither a $ref nor a PathItem in Document.paths['/hello/world']. \n\nReference could not be decoded because:\nProblem encountered when parsing `$ref`: Expected a reference string, but found an empty string instead..." ) XCTAssertEqual(openAPIError.codingPath.map { $0.stringValue }, ["paths", "/hello/world"]) } @@ -50,7 +50,7 @@ final class PathsErrorTests: XCTestCase { let openAPIError = OpenAPI.Error(from: error) - XCTAssertEqual(openAPIError.localizedDescription, "Found neither a $ref nor a PathItem in Document.paths['/hello/world']. \n\nPathItem could not be decoded because:\nInconsistency encountered when parsing `Vendor Extension` under the `/hello/world` path: Found at least one vendor extension property that does not begin with the required 'x-' prefix. Invalid properties: [ boo ].." + XCTAssertEqual(openAPIError.localizedDescription, "Found neither a $ref nor a PathItem in Document.paths['/hello/world']. \n\nPathItem could not be decoded because:\nProblem encountered when parsing `Vendor Extension` under the `/hello/world` path: Found at least one vendor extension property that does not begin with the required 'x-' prefix. Invalid properties: [ boo ].." ) XCTAssertEqual(openAPIError.codingPath.map { $0.stringValue }, ["paths", "/hello/world"]) } @@ -131,7 +131,7 @@ final class PathsErrorTests: XCTestCase { let openAPIError = OpenAPI.Error(from: error) - XCTAssertEqual(openAPIError.localizedDescription, "Found neither a $ref nor a Parameter in .parameters[0] under the `/hello/world` path. \n\nParameter could not be decoded because:\nInconsistency encountered when parsing `world`: positional path parameters must be explicitly set to required.." + XCTAssertEqual(openAPIError.localizedDescription, "Found neither a $ref nor a Parameter in .parameters[0] under the `/hello/world` path. \n\nParameter could not be decoded because:\nProblem encountered when parsing `world`: positional path parameters must be explicitly set to required.." ) XCTAssertEqual( openAPIError.codingPath.map { $0.stringValue }, @@ -164,7 +164,7 @@ final class PathsErrorTests: XCTestCase { let openAPIError = OpenAPI.Error(from: error) - XCTAssertEqual(openAPIError.localizedDescription, "Found neither a $ref nor a Parameter in .parameters[0] under the `/hello/world` path. \n\nParameter could not be decoded because:\nInconsistency encountered when parsing `world`: A parameter must specify either `content` or `schema`.." + XCTAssertEqual(openAPIError.localizedDescription, "Found neither a $ref nor a Parameter in .parameters[0] under the `/hello/world` path. \n\nParameter could not be decoded because:\nProblem encountered when parsing `world`: A parameter must specify either `content` or `schema`.." ) XCTAssertEqual( openAPIError.codingPath.map { $0.stringValue }, @@ -203,7 +203,7 @@ final class PathsErrorTests: XCTestCase { let openAPIError = OpenAPI.Error(from: error) - XCTAssertEqual(openAPIError.localizedDescription, "Found neither a $ref nor a Parameter in .parameters[0] under the `/hello/world` path. \n\nParameter could not be decoded because:\nInconsistency encountered when parsing `world`: A parameter must specify one but not both `content` and `schema`.." + XCTAssertEqual(openAPIError.localizedDescription, "Found neither a $ref nor a Parameter in .parameters[0] under the `/hello/world` path. \n\nParameter could not be decoded because:\nProblem encountered when parsing `world`: A parameter must specify one but not both `content` and `schema`.." ) XCTAssertEqual( openAPIError.codingPath.map { $0.stringValue }, @@ -246,7 +246,7 @@ final class PathsErrorTests: XCTestCase { XCTAssertEqual( openAPIError?.localizedDescription, """ - Inconsistency encountered when parsing `OpenAPI Schema`: Found schema attributes not consistent with the type specified: object. Specifically, attributes for these other types: [\"array\"]. + Problem encountered when parsing `OpenAPI Schema`: Found schema attributes not consistent with the type specified: object. Specifically, attributes for these other types: [\"array\"]. """ ) XCTAssertEqual( diff --git a/Tests/OpenAPIKitErrorReportingTests/RequestContentMapErrorTests.swift b/Tests/OpenAPIKitErrorReportingTests/RequestContentMapErrorTests.swift index 685b52402..7771fe7a6 100644 --- a/Tests/OpenAPIKitErrorReportingTests/RequestContentMapErrorTests.swift +++ b/Tests/OpenAPIKitErrorReportingTests/RequestContentMapErrorTests.swift @@ -107,7 +107,7 @@ final class RequestContentMapErrorTests: XCTestCase { let openAPIError = OpenAPI.Error(from: error) - XCTAssertEqual(openAPIError.localizedDescription, "Inconsistency encountered when parsing `Vendor Extension` in .content['application/json'] for the request body of the **GET** endpoint under `/hello/world`: Found at least one vendor extension property that does not begin with the required 'x-' prefix. Invalid properties: [ invalid ].") + XCTAssertEqual(openAPIError.localizedDescription, "Problem encountered when parsing `Vendor Extension` in .content['application/json'] for the request body of the **GET** endpoint under `/hello/world`: Found at least one vendor extension property that does not begin with the required 'x-' prefix. Invalid properties: [ invalid ].") XCTAssertEqual(openAPIError.codingPath.map { $0.stringValue }, [ "paths", "/hello/world", diff --git a/Tests/OpenAPIKitErrorReportingTests/ResponseErrorTests.swift b/Tests/OpenAPIKitErrorReportingTests/ResponseErrorTests.swift index 99323a737..fba1f7fd3 100644 --- a/Tests/OpenAPIKitErrorReportingTests/ResponseErrorTests.swift +++ b/Tests/OpenAPIKitErrorReportingTests/ResponseErrorTests.swift @@ -39,7 +39,7 @@ final class ResponseErrorTests: XCTestCase { let openAPIError = OpenAPI.Error(from: error) - XCTAssertEqual(openAPIError.localizedDescription, "Found neither a $ref nor a Header in .headers.hi for the status code '200' response of the **GET** endpoint under `/hello/world`. \n\nHeader could not be decoded because:\nInconsistency encountered when parsing `Header`: A header must specify one but not both `content` and `schema`..") + XCTAssertEqual(openAPIError.localizedDescription, "Found neither a $ref nor a Header in .headers.hi for the status code '200' response of the **GET** endpoint under `/hello/world`. \n\nHeader could not be decoded because:\nProblem encountered when parsing `Header`: A header must specify one but not both `content` and `schema`..") XCTAssertEqual(openAPIError.codingPath.map { $0.stringValue }, [ "paths", "/hello/world", @@ -102,7 +102,7 @@ final class ResponseErrorTests: XCTestCase { let openAPIError = OpenAPI.Error(from: error) - XCTAssertEqual(openAPIError.localizedDescription, "Found neither a $ref nor a Response in .responses.200 for the **GET** endpoint under `/hello/world`. \n\nResponse could not be decoded because:\nInconsistency encountered when parsing `Vendor Extension`: Found at least one vendor extension property that does not begin with the required 'x-' prefix. Invalid properties: [ not-a-thing ]..") + XCTAssertEqual(openAPIError.localizedDescription, "Found neither a $ref nor a Response in .responses.200 for the **GET** endpoint under `/hello/world`. \n\nResponse could not be decoded because:\nProblem encountered when parsing `Vendor Extension`: Found at least one vendor extension property that does not begin with the required 'x-' prefix. Invalid properties: [ not-a-thing ]..") XCTAssertEqual(openAPIError.codingPath.map { $0.stringValue }, [ "paths", "/hello/world", diff --git a/Tests/OpenAPIKitErrorReportingTests/SchemaErrorTests.swift b/Tests/OpenAPIKitErrorReportingTests/SchemaErrorTests.swift index ede89a305..deeb1f6cb 100644 --- a/Tests/OpenAPIKitErrorReportingTests/SchemaErrorTests.swift +++ b/Tests/OpenAPIKitErrorReportingTests/SchemaErrorTests.swift @@ -35,7 +35,7 @@ final class SchemaErrorTests: XCTestCase { let openAPIError = OpenAPI.Error(from: error) - XCTAssertEqual(openAPIError.localizedDescription, "Found neither a $ref nor a JSONSchema in .content['application/json'].schema for the status code '200' response of the **GET** endpoint under `/hello/world`. \n\nJSONSchema could not be decoded because:\nInconsistency encountered when parsing `maximum`: Expected an Integer literal but found a floating point value (1.234)..") + XCTAssertEqual(openAPIError.localizedDescription, "Found neither a $ref nor a JSONSchema in .content['application/json'].schema for the status code '200' response of the **GET** endpoint under `/hello/world`. \n\nJSONSchema could not be decoded because:\nProblem encountered when parsing `maximum`: Expected an Integer literal but found a floating point value (1.234)..") XCTAssertEqual(openAPIError.codingPath.map { $0.stringValue }, [ "paths", "/hello/world", @@ -76,7 +76,7 @@ final class SchemaErrorTests: XCTestCase { XCTAssertEqual(openAPIError.localizedDescription, """ - Inconsistency encountered when parsing `OpenAPI Schema`: Found 'nullable' property. This property is not supported by OpenAPI v3.1.x. OpenAPIKit has translated it into 'type: ["null", ...]'.. at path: .paths['/hello/world'].get.responses.200.content['application/json'].schema + Problem encountered when parsing `OpenAPI Schema`: Found 'nullable' property. This property is not supported by OpenAPI v3.1.x. OpenAPIKit has translated it into 'type: ["null", ...]'.. at path: .paths['/hello/world'].get.responses.200.content['application/json'].schema """) XCTAssertEqual(openAPIError.codingPath.map { $0.stringValue }, [ "paths", diff --git a/Tests/OpenAPIKitErrorReportingTests/SecuritySchemeErrorTests.swift b/Tests/OpenAPIKitErrorReportingTests/SecuritySchemeErrorTests.swift index f5f2e2081..3bab740c9 100644 --- a/Tests/OpenAPIKitErrorReportingTests/SecuritySchemeErrorTests.swift +++ b/Tests/OpenAPIKitErrorReportingTests/SecuritySchemeErrorTests.swift @@ -29,7 +29,7 @@ final class SecuritySchemeErrorTests: XCTestCase { let openAPIError = OpenAPI.Error(from: error) - XCTAssertEqual(openAPIError.localizedDescription, "Inconsistency encountered when parsing `security` in the root Document object: Each key found in a Security Requirement dictionary must refer to a Security Scheme present in the Components dictionary.") + XCTAssertEqual(openAPIError.localizedDescription, "Problem encountered when parsing `security` in the root Document object: Each key found in a Security Requirement dictionary must refer to a Security Scheme present in the Components dictionary.") XCTAssertEqual(openAPIError.codingPath.map { $0.stringValue }, [ "security" ]) @@ -61,7 +61,7 @@ final class SecuritySchemeErrorTests: XCTestCase { let openAPIError = OpenAPI.Error(from: error) - XCTAssertEqual(openAPIError.localizedDescription, "Inconsistency encountered when parsing `hello` in Document.paths['/hello/world'].get.security: Each key found in a Security Requirement dictionary must refer to a Security Scheme present in the Components dictionary.") + XCTAssertEqual(openAPIError.localizedDescription, "Problem encountered when parsing `hello` in Document.paths['/hello/world'].get.security: Each key found in a Security Requirement dictionary must refer to a Security Scheme present in the Components dictionary.") XCTAssertEqual(openAPIError.codingPath.map { $0.stringValue }, [ "paths", "/hello/world", diff --git a/Tests/OpenAPIKitTests/Document/DocumentInfoTests.swift b/Tests/OpenAPIKitTests/Document/DocumentInfoTests.swift index 6106b934e..6c81c879d 100644 --- a/Tests/OpenAPIKitTests/Document/DocumentInfoTests.swift +++ b/Tests/OpenAPIKitTests/Document/DocumentInfoTests.swift @@ -483,7 +483,7 @@ extension DocumentInfoTests { } """.data(using: .utf8)! XCTAssertThrowsError(try orderUnstableDecode(OpenAPI.Document.Info.self, from: infoData)) { error in - XCTAssertEqual(OpenAPI.Error(from: error).localizedDescription, "Inconsistency encountered when parsing `termsOfService`: If specified, must be a valid URL.") + XCTAssertEqual(OpenAPI.Error(from: error).localizedDescription, "Problem encountered when parsing `termsOfService`: If specified, must be a valid URL.") } } diff --git a/Tests/OpenAPIKitTests/Document/DocumentTests.swift b/Tests/OpenAPIKitTests/Document/DocumentTests.swift index 1de075b87..15461b05c 100644 --- a/Tests/OpenAPIKitTests/Document/DocumentTests.swift +++ b/Tests/OpenAPIKitTests/Document/DocumentTests.swift @@ -579,7 +579,7 @@ extension DocumentTests { } } """.data(using: .utf8)! - XCTAssertThrowsError(try orderUnstableDecode(OpenAPI.Document.self, from: documentData)) { error in XCTAssertEqual(OpenAPI.Error(from: error).localizedDescription, "Inconsistency encountered when parsing `openapi` in the root Document object: Cannot initialize Version from invalid String value 3.1.9.") } + XCTAssertThrowsError(try orderUnstableDecode(OpenAPI.Document.self, from: documentData)) { error in XCTAssertEqual(OpenAPI.Error(from: error).localizedDescription, "Problem encountered when parsing `openapi` in the root Document object: Cannot initialize Version from invalid String value 3.1.9.") } } func test_specifyServers_encode() throws { diff --git a/Tests/OpenAPIKitTests/ExternalDocumentationTests.swift b/Tests/OpenAPIKitTests/ExternalDocumentationTests.swift index 452494908..abd06b593 100644 --- a/Tests/OpenAPIKitTests/ExternalDocumentationTests.swift +++ b/Tests/OpenAPIKitTests/ExternalDocumentationTests.swift @@ -140,7 +140,7 @@ extension ExternalDocumentationTests { """.data(using: .utf8)! XCTAssertThrowsError(try orderUnstableDecode(OpenAPI.ExternalDocumentation.self, from: externalDocsData)) { error in - XCTAssertEqual(OpenAPI.Error(from: error).localizedDescription, "Inconsistency encountered when parsing `url`: If specified, must be a valid URL.") + XCTAssertEqual(OpenAPI.Error(from: error).localizedDescription, "Problem encountered when parsing `url`: If specified, must be a valid URL.") } } } diff --git a/Tests/OpenAPIKitTests/Schema Object/JSONSchemaTests.swift b/Tests/OpenAPIKitTests/Schema Object/JSONSchemaTests.swift index 2f7ca5a47..969002ee4 100644 --- a/Tests/OpenAPIKitTests/Schema Object/JSONSchemaTests.swift +++ b/Tests/OpenAPIKitTests/Schema Object/JSONSchemaTests.swift @@ -1704,7 +1704,7 @@ extension SchemaObjectTests { XCTAssertEqual(warnResult.warnings.count, 1) // NOTE: not the most informative warnings, would like to do better. - XCTAssertEqual(warnResult.warnings.first?.localizedDescription, "Inconsistency encountered when parsing `OpenAPI Schema`: Found nothing but unsupported attributes..") + XCTAssertEqual(warnResult.warnings.first?.localizedDescription, "Problem encountered when parsing `OpenAPI Schema`: Found nothing but unsupported attributes..") // we are actually at the root path in this test case so the // following should be an empty string! XCTAssertEqual(warnResult.warnings.first?.codingPathString, "") @@ -1763,7 +1763,7 @@ extension SchemaObjectTests { let warnResult = try orderUnstableDecode(JSONSchema.self, from: badSchema) XCTAssertEqual(warnResult.warnings.count, 1) - XCTAssertEqual(warnResult.warnings.first?.localizedDescription, "Inconsistency encountered when parsing `OpenAPI Schema`: Found schema attributes not consistent with the type specified: object. Specifically, attributes for these other types: [\"array\"].") + XCTAssertEqual(warnResult.warnings.first?.localizedDescription, "Problem encountered when parsing `OpenAPI Schema`: Found schema attributes not consistent with the type specified: object. Specifically, attributes for these other types: [\"array\"].") // we are actually at the root path in this test case so the // following should be an empty string! XCTAssertEqual(warnResult.warnings.first?.codingPathString, "") diff --git a/Tests/OpenAPIKitTests/Schema Object/SchemaFragmentTests.swift b/Tests/OpenAPIKitTests/Schema Object/SchemaFragmentTests.swift index 40f45a7cf..2fbcfdee9 100644 --- a/Tests/OpenAPIKitTests/Schema Object/SchemaFragmentTests.swift +++ b/Tests/OpenAPIKitTests/Schema Object/SchemaFragmentTests.swift @@ -160,7 +160,7 @@ extension SchemaFragmentTests { let warnResult = try orderUnstableDecode(JSONSchema.self, from: t) XCTAssertEqual(warnResult.warnings.count, 1) - XCTAssertEqual(warnResult.warnings.first?.localizedDescription, "Inconsistency encountered when parsing `Schema`: A schema contains properties for multiple types of schemas, namely: [\"array\", \"object\"]..") + XCTAssertEqual(warnResult.warnings.first?.localizedDescription, "Problem encountered when parsing `Schema`: A schema contains properties for multiple types of schemas, namely: [\"array\", \"object\"]..") // we are actually at the root path in this test case so the // following should be an empty string! XCTAssertEqual(warnResult.warnings.first?.codingPathString, "") @@ -182,7 +182,7 @@ extension SchemaFragmentTests { let warnResult = try orderUnstableDecode(JSONSchema.self, from: t) XCTAssertEqual(warnResult.warnings.count, 1) - XCTAssertEqual(warnResult.warnings.first?.localizedDescription, "Inconsistency encountered when parsing `OpenAPI Schema`: Found schema attributes not consistent with the type specified: object. Specifically, attributes for these other types: [\"array\"].") + XCTAssertEqual(warnResult.warnings.first?.localizedDescription, "Problem encountered when parsing `OpenAPI Schema`: Found schema attributes not consistent with the type specified: object. Specifically, attributes for these other types: [\"array\"].") // we are actually at the root path in this test case so the // following should be an empty string! XCTAssertEqual(warnResult.warnings.first?.codingPathString, "") @@ -222,7 +222,7 @@ extension SchemaFragmentTests { XCTAssertEqual(warnResult1.warnings.count, 1) // NOTE: Not a very informative warning, would like to do better. - XCTAssertEqual(warnResult1.warnings.first?.localizedDescription, "Inconsistency encountered when parsing `OpenAPI Schema`: Found nothing but unsupported attributes..") + XCTAssertEqual(warnResult1.warnings.first?.localizedDescription, "Problem encountered when parsing `OpenAPI Schema`: Found nothing but unsupported attributes..") // we are actually at the root path in this test case so the // following should be an empty string! XCTAssertEqual(warnResult1.warnings.first?.codingPathString, "") @@ -231,7 +231,7 @@ extension SchemaFragmentTests { XCTAssertEqual(warnResult2.warnings.count, 1) // NOTE: Not a very informative warning, would like to do better. - XCTAssertEqual(warnResult2.warnings.first?.localizedDescription, "Inconsistency encountered when parsing `OpenAPI Schema`: Found nothing but unsupported attributes..") + XCTAssertEqual(warnResult2.warnings.first?.localizedDescription, "Problem encountered when parsing `OpenAPI Schema`: Found nothing but unsupported attributes..") // we are actually at the root path in this test case so the // following should be an empty string! XCTAssertEqual(warnResult2.warnings.first?.codingPathString, "") diff --git a/Tests/OpenAPIKitTests/Schema Object/SchemaObjectYamsTests.swift b/Tests/OpenAPIKitTests/Schema Object/SchemaObjectYamsTests.swift index 17bf08876..233cb9055 100644 --- a/Tests/OpenAPIKitTests/Schema Object/SchemaObjectYamsTests.swift +++ b/Tests/OpenAPIKitTests/Schema Object/SchemaObjectYamsTests.swift @@ -54,7 +54,7 @@ final class SchemaObjectYamsTests: XCTestCase { """ XCTAssertThrowsError(try YAMLDecoder().decode(JSONSchema.self, from: integerString)) { error in - XCTAssertEqual(OpenAPI.Error(from: error).localizedDescription, "Inconsistency encountered when parsing `maximum`: Expected an Integer literal but found a floating point value (10.2).") + XCTAssertEqual(OpenAPI.Error(from: error).localizedDescription, "Problem encountered when parsing `maximum`: Expected an Integer literal but found a floating point value (10.2).") } let integerString2 = @@ -64,7 +64,7 @@ final class SchemaObjectYamsTests: XCTestCase { """ XCTAssertThrowsError(try YAMLDecoder().decode(JSONSchema.self, from: integerString2)) { error in - XCTAssertEqual(OpenAPI.Error(from: error).localizedDescription, "Inconsistency encountered when parsing `minimum`: Expected an Integer literal but found a floating point value (1.1).") + XCTAssertEqual(OpenAPI.Error(from: error).localizedDescription, "Problem encountered when parsing `minimum`: Expected an Integer literal but found a floating point value (1.1).") } } } diff --git a/Tests/OpenAPIKitTests/Validator/ValidatorTests.swift b/Tests/OpenAPIKitTests/Validator/ValidatorTests.swift index d8351cade..e5ed9f59f 100644 --- a/Tests/OpenAPIKitTests/Validator/ValidatorTests.swift +++ b/Tests/OpenAPIKitTests/Validator/ValidatorTests.swift @@ -1445,7 +1445,7 @@ final class ValidatorTests: XCTestCase { XCTAssertEqual(warnings.count, 1) XCTAssertEqual( warnings.first?.localizedDescription, - "Inconsistency encountered when parsing ``: \'gzip\' could not be parsed as a Content Type. Content Types should have the format \'/\'." + "Problem encountered when parsing ``: \'gzip\' could not be parsed as a Content Type. Content Types should have the format \'/\'." ) XCTAssertEqual(warnings.first?.codingPathString, ".paths[\'/test\'].get.responses.200.content") } @@ -1484,7 +1484,7 @@ final class ValidatorTests: XCTestCase { XCTAssertEqual(errors?.values.count, 1) XCTAssertEqual( errors?.localizedDescription, - "Inconsistency encountered when parsing ``: \'gzip\' could not be parsed as a Content Type. Content Types should have the format \'/\'. at path: .paths[\'/test\'].get.responses.200.content" + "Problem encountered when parsing ``: \'gzip\' could not be parsed as a Content Type. Content Types should have the format \'/\'. at path: .paths[\'/test\'].get.responses.200.content" ) XCTAssertEqual(errors?.values.first?.codingPathString, ".paths[\'/test\'].get.responses.200.content") } From 35f095a35fb8da4803af823371fe85f00c204986 Mon Sep 17 00:00:00 2001 From: Mathew Polzin Date: Sun, 18 May 2025 21:46:27 -0500 Subject: [PATCH 3/3] Add to migration guide --- documentation/v4_migration_guide.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/documentation/v4_migration_guide.md b/documentation/v4_migration_guide.md index d4b4a61a5..dd5b744a2 100644 --- a/documentation/v4_migration_guide.md +++ b/documentation/v4_migration_guide.md @@ -79,3 +79,11 @@ The default (fallback) implementations of `inferred`, `anchor`, and `dynamicAnchor` have been removed. Almost no downstream code will break because of this, but if you've implemented the `JSONSchemaContext` protocol yourself then this note is for you. + +### Errors +The `InconsistencyError` type has been renaemd to `GenericError` and its message +has been tweaked to fit the new name. This error has been used to represent many +errors over time and I would not classify all of them as "inconsistencies." + +If you've used the error's type or rely on the exact message, you will need to +update your code accordingly.