diff --git a/openapi_core/unmarshalling/schemas/unmarshallers.py b/openapi_core/unmarshalling/schemas/unmarshallers.py index 941e28cb..9329dc78 100644 --- a/openapi_core/unmarshalling/schemas/unmarshallers.py +++ b/openapi_core/unmarshalling/schemas/unmarshallers.py @@ -292,7 +292,7 @@ def _unmarshal_properties(self, value: Any) -> Any: if additional_properties is not False: # free-form object if additional_properties is True: - additional_prop_schema = Spec.from_dict({}) + additional_prop_schema = Spec.from_dict({"nullable": True}) # defined schema else: additional_prop_schema = self.schema / "additionalProperties" diff --git a/tests/integration/validation/test_petstore.py b/tests/integration/validation/test_petstore.py index c52feeb3..6925bbf9 100644 --- a/tests/integration/validation/test_petstore.py +++ b/tests/integration/validation/test_petstore.py @@ -752,6 +752,7 @@ def test_post_cats(self, spec, spec_dict): "ears": { "healthy": pet_healthy, }, + "extra": None, } data = json.dumps(data_json) headers = { @@ -799,6 +800,7 @@ def test_post_cats(self, spec, spec_dict): assert result.body.address.street == pet_street assert result.body.address.city == pet_city assert result.body.healthy == pet_healthy + assert result.body.extra is None def test_post_cats_boolean_string(self, spec, spec_dict): host_url = "https://staging.gigantic-server.com/v1"