@@ -1976,7 +1976,10 @@ extension JSONSchema: Decodable {
19761976 schema = schema. nullableSchemaObject ( )
19771977 }
19781978
1979- self = schema
1979+ // Ad-hoc vendor extension support since JSONSchema does coding keys differently.
1980+ let extensions = try Self . decodeVenderExtensions ( from: decoder)
1981+
1982+ self = schema. with ( vendorExtensions: extensions)
19801983 return
19811984 }
19821985
@@ -1993,7 +1996,10 @@ extension JSONSchema: Decodable {
19931996 schema = schema. nullableSchemaObject ( )
19941997 }
19951998
1996- self = schema
1999+ // Ad-hoc vendor extension support since JSONSchema does coding keys differently.
2000+ let extensions = try Self . decodeVenderExtensions ( from: decoder)
2001+
2002+ self = schema. with ( vendorExtensions: extensions)
19972003 return
19982004 }
19992005
@@ -2009,7 +2015,10 @@ extension JSONSchema: Decodable {
20092015 schema = schema. nullableSchemaObject ( )
20102016 }
20112017
2012- self = schema
2018+ // Ad-hoc vendor extension support since JSONSchema does coding keys differently.
2019+ let extensions = try Self . decodeVenderExtensions ( from: decoder)
2020+
2021+ self = schema. with ( vendorExtensions: extensions)
20132022 return
20142023 }
20152024
@@ -2021,8 +2030,11 @@ extension JSONSchema: Decodable {
20212030 core: coreContext
20222031 )
20232032 )
2024-
2025- self = schema
2033+
2034+ // Ad-hoc vendor extension support since JSONSchema does coding keys differently.
2035+ let extensions = try Self . decodeVenderExtensions ( from: decoder)
2036+
2037+ self = schema. with ( vendorExtensions: extensions)
20262038 return
20272039 }
20282040
@@ -2137,29 +2149,30 @@ extension JSONSchema: Decodable {
21372149
21382150 self . warnings = _warnings
21392151
2140- // Ad-hoc vendor extension support since JSONSchema does coding keys differently.
2141- let extensions : [ String : AnyCodable ]
2152+ // Ad-hoc vendor extension support since JSONSchema does coding keys differently.
2153+ let extensions = try Self . decodeVenderExtensions ( from : decoder )
21422154
2155+ self . value = value. with ( vendorExtensions: extensions)
2156+ }
2157+
2158+ private static func decodeVenderExtensions( from decoder: Decoder ) throws -> [ String : AnyCodable ] {
21432159 guard VendorExtensionsConfiguration . isEnabled ( for: decoder) else {
2144- self . value = value
2145- return
2160+ return [ : ]
21462161 }
2147-
2162+
21482163 let decoded = try AnyCodable ( from: decoder) . value
2149-
2164+
21502165 guard ( decoded as? [ Any ] ) == nil else {
21512166 throw VendorExtensionDecodingError . selfIsArrayNotDict
21522167 }
21532168
21542169 guard let decodedAny = decoded as? [ String : any Sendable ] else {
21552170 throw VendorExtensionDecodingError . foundNonStringKeys
21562171 }
2157-
2158- extensions = decodedAny
2172+
2173+ return decodedAny
21592174 . filter { $0. key. lowercased ( ) . starts ( with: " x- " ) }
21602175 . mapValues ( AnyCodable . init)
2161-
2162- self . value = value. with ( vendorExtensions: extensions)
21632176 }
21642177
21652178 private static func decodeTypes( from container: KeyedDecodingContainer < JSONSchema . HintCodingKeys > ) throws -> [ JSONType ] {
0 commit comments