File tree Expand file tree Collapse file tree 3 files changed +12
-4
lines changed
Encoding and Decoding Errors
Tests/OpenAPIKitErrorReportingTests Expand file tree Collapse file tree 3 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -70,6 +70,11 @@ extension OpenAPI.Error.Decoding.Response {
7070
7171 internal init ( _ error: GenericError ) {
7272 var codingPath = Self . relativePath ( from: error. codingPath)
73+
74+ if error. pathIncludesSubject {
75+ codingPath = codingPath. dropLast ( )
76+ }
77+
7378 let code = codingPath. removeFirst ( ) . stringValue. lowercased ( )
7479
7580 // this part of the coding path is structurally guaranteed to be a status code
Original file line number Diff line number Diff line change @@ -1173,11 +1173,13 @@ extension JSONSchema.IntegerContext: Decodable {
11731173 let value = try intAttempt
11741174 ?? doubleAttempt. map { floatVal in
11751175 guard let integer = Int ( exactly: floatVal) else {
1176+ let key = max ? CodingKeys . maximum : CodingKeys . minimum
1177+ let subject = key. rawValue
11761178 throw GenericError (
1177- subjectName: max ? " maximum " : " minimum " ,
1179+ subjectName: subject ,
11781180 details: " Expected an Integer literal but found a floating point value ( \( String ( describing: floatVal) ) ) " ,
1179- codingPath: decoder. codingPath,
1180- pathIncludesSubject: false
1181+ codingPath: decoder. codingPath + [ key ] ,
1182+ pathIncludesSubject: true
11811183 )
11821184 }
11831185 return integer
Original file line number Diff line number Diff line change @@ -44,7 +44,8 @@ final class SchemaErrorTests: XCTestCase {
4444 " 200 " ,
4545 " content " ,
4646 " application/json " ,
47- " schema "
47+ " schema " ,
48+ " maximum "
4849 ] )
4950 }
5051 }
You can’t perform that action at this time.
0 commit comments