diff --git a/Sources/OpenAPIRuntime/Conversion/ErrorExtensions.swift b/Sources/OpenAPIRuntime/Conversion/ErrorExtensions.swift index cb4cbef2..1ad5651d 100644 --- a/Sources/OpenAPIRuntime/Conversion/ErrorExtensions.swift +++ b/Sources/OpenAPIRuntime/Conversion/ErrorExtensions.swift @@ -35,6 +35,28 @@ extension DecodingError { ) ) } + + /// Returns a decoding error used by the oneOf decoder when not a single + /// child schema decodes the received payload. + /// - Parameters: + /// - type: The type representing the oneOf schema in which the decoding + /// occurred. + /// - codingPath: The coding path to the decoder that attempted to decode + /// the type. + /// - Returns: A decoding error. + @_spi(Generated) + public static func failedToDecodeOneOfSchema( + type: Any.Type, + codingPath: [any CodingKey] + ) -> Self { + DecodingError.valueNotFound( + type, + DecodingError.Context.init( + codingPath: codingPath, + debugDescription: "The oneOf structure did not decode into any child schema." + ) + ) + } } @_spi(Generated)