From d3d3c0fc1f506faf236d0436f8860203f97cae1b Mon Sep 17 00:00:00 2001 From: p1c2u Date: Thu, 5 Mar 2026 11:09:44 +0000 Subject: [PATCH] Add oas32_schema_casters_factory --- openapi_core/casting/schemas/__init__.py | 7 +++++++ openapi_core/unmarshalling/schemas/__init__.py | 4 +++- openapi_core/validation/request/validators.py | 17 +++++++++-------- openapi_core/validation/response/validators.py | 13 +++++++------ 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/openapi_core/casting/schemas/__init__.py b/openapi_core/casting/schemas/__init__.py index 18b1a9e3..39c14a4e 100644 --- a/openapi_core/casting/schemas/__init__.py +++ b/openapi_core/casting/schemas/__init__.py @@ -15,11 +15,13 @@ oas30_write_schema_validators_factory, ) from openapi_core.validation.schemas import oas31_schema_validators_factory +from openapi_core.validation.schemas import oas32_schema_validators_factory __all__ = [ "oas30_write_schema_casters_factory", "oas30_read_schema_casters_factory", "oas31_schema_casters_factory", + "oas32_schema_casters_factory", ] oas30_casters_dict = OrderedDict( @@ -48,6 +50,7 @@ PrimitiveCaster, multi=PrimitiveCaster, ) +oas32_types_caster = oas31_types_caster oas30_write_schema_casters_factory = SchemaCastersFactory( oas30_write_schema_validators_factory, @@ -63,3 +66,7 @@ oas31_schema_validators_factory, oas31_types_caster, ) +oas32_schema_casters_factory = SchemaCastersFactory( + oas32_schema_validators_factory, + oas32_types_caster, +) diff --git a/openapi_core/unmarshalling/schemas/__init__.py b/openapi_core/unmarshalling/schemas/__init__.py index 0cc2f0ff..300d52ec 100644 --- a/openapi_core/unmarshalling/schemas/__init__.py +++ b/openapi_core/unmarshalling/schemas/__init__.py @@ -30,6 +30,7 @@ __all__ = [ "oas30_format_unmarshallers", "oas31_format_unmarshallers", + "oas32_format_unmarshallers", "oas30_write_schema_unmarshallers_factory", "oas30_read_schema_unmarshallers_factory", "oas31_schema_unmarshallers_factory", @@ -67,6 +68,7 @@ AnyUnmarshaller, multi=MultiTypeUnmarshaller, ) +oas32_types_unmarshaller = oas31_types_unmarshaller oas30_format_unmarshallers = { # string compatible @@ -102,7 +104,7 @@ oas32_schema_unmarshallers_factory = SchemaUnmarshallersFactory( oas32_schema_validators_factory, - oas31_types_unmarshaller, + oas32_types_unmarshaller, format_unmarshallers=oas32_format_unmarshallers, ) diff --git a/openapi_core/validation/request/validators.py b/openapi_core/validation/request/validators.py index 808d1b5b..ede517f1 100644 --- a/openapi_core/validation/request/validators.py +++ b/openapi_core/validation/request/validators.py @@ -14,6 +14,7 @@ from openapi_core.casting.schemas import oas30_write_schema_casters_factory from openapi_core.casting.schemas import oas31_schema_casters_factory +from openapi_core.casting.schemas import oas32_schema_casters_factory from openapi_core.casting.schemas.factories import SchemaCastersFactory from openapi_core.datatypes import Parameters from openapi_core.datatypes import RequestParameters @@ -482,47 +483,47 @@ class V31WebhookRequestValidator(WebhookRequestValidator): class V32RequestBodyValidator(APICallRequestBodyValidator): spec_validator_cls = OpenAPIV32SpecValidator - schema_casters_factory = oas31_schema_casters_factory + schema_casters_factory = oas32_schema_casters_factory schema_validators_factory = oas32_schema_validators_factory class V32RequestParametersValidator(APICallRequestParametersValidator): spec_validator_cls = OpenAPIV32SpecValidator - schema_casters_factory = oas31_schema_casters_factory + schema_casters_factory = oas32_schema_casters_factory schema_validators_factory = oas32_schema_validators_factory class V32RequestSecurityValidator(APICallRequestSecurityValidator): spec_validator_cls = OpenAPIV32SpecValidator - schema_casters_factory = oas31_schema_casters_factory + schema_casters_factory = oas32_schema_casters_factory schema_validators_factory = oas32_schema_validators_factory class V32RequestValidator(APICallRequestValidator): spec_validator_cls = OpenAPIV32SpecValidator - schema_casters_factory = oas31_schema_casters_factory + schema_casters_factory = oas32_schema_casters_factory schema_validators_factory = oas32_schema_validators_factory class V32WebhookRequestBodyValidator(WebhookRequestBodyValidator): spec_validator_cls = OpenAPIV32SpecValidator - schema_casters_factory = oas31_schema_casters_factory + schema_casters_factory = oas32_schema_casters_factory schema_validators_factory = oas32_schema_validators_factory class V32WebhookRequestParametersValidator(WebhookRequestParametersValidator): spec_validator_cls = OpenAPIV32SpecValidator - schema_casters_factory = oas31_schema_casters_factory + schema_casters_factory = oas32_schema_casters_factory schema_validators_factory = oas32_schema_validators_factory class V32WebhookRequestSecurityValidator(WebhookRequestSecurityValidator): spec_validator_cls = OpenAPIV32SpecValidator - schema_casters_factory = oas31_schema_casters_factory + schema_casters_factory = oas32_schema_casters_factory schema_validators_factory = oas32_schema_validators_factory class V32WebhookRequestValidator(WebhookRequestValidator): spec_validator_cls = OpenAPIV32SpecValidator - schema_casters_factory = oas31_schema_casters_factory + schema_casters_factory = oas32_schema_casters_factory schema_validators_factory = oas32_schema_validators_factory diff --git a/openapi_core/validation/response/validators.py b/openapi_core/validation/response/validators.py index 2a436082..8ffefc48 100644 --- a/openapi_core/validation/response/validators.py +++ b/openapi_core/validation/response/validators.py @@ -15,6 +15,7 @@ from openapi_core.casting.schemas import oas30_read_schema_casters_factory from openapi_core.casting.schemas import oas31_schema_casters_factory +from openapi_core.casting.schemas import oas32_schema_casters_factory from openapi_core.exceptions import OpenAPIError from openapi_core.protocols import HeadersType from openapi_core.protocols import Request @@ -410,35 +411,35 @@ class V31WebhookResponseValidator(WebhookResponseValidator): class V32ResponseDataValidator(APICallResponseDataValidator): spec_validator_cls = OpenAPIV32SpecValidator - schema_casters_factory = oas31_schema_casters_factory + schema_casters_factory = oas32_schema_casters_factory schema_validators_factory = oas32_schema_validators_factory class V32ResponseHeadersValidator(APICallResponseHeadersValidator): spec_validator_cls = OpenAPIV32SpecValidator - schema_casters_factory = oas31_schema_casters_factory + schema_casters_factory = oas32_schema_casters_factory schema_validators_factory = oas32_schema_validators_factory class V32ResponseValidator(APICallResponseValidator): spec_validator_cls = OpenAPIV32SpecValidator - schema_casters_factory = oas31_schema_casters_factory + schema_casters_factory = oas32_schema_casters_factory schema_validators_factory = oas32_schema_validators_factory class V32WebhookResponseDataValidator(WebhookResponseDataValidator): spec_validator_cls = OpenAPIV32SpecValidator - schema_casters_factory = oas31_schema_casters_factory + schema_casters_factory = oas32_schema_casters_factory schema_validators_factory = oas32_schema_validators_factory class V32WebhookResponseHeadersValidator(WebhookResponseHeadersValidator): spec_validator_cls = OpenAPIV32SpecValidator - schema_casters_factory = oas31_schema_casters_factory + schema_casters_factory = oas32_schema_casters_factory schema_validators_factory = oas32_schema_validators_factory class V32WebhookResponseValidator(WebhookResponseValidator): spec_validator_cls = OpenAPIV32SpecValidator - schema_casters_factory = oas31_schema_casters_factory + schema_casters_factory = oas32_schema_casters_factory schema_validators_factory = oas32_schema_validators_factory