Closed
Description
I'm still working on minimal reproducer to prove this out so apologies for the lack of a one in advance.
I've got a schema like this:
openapi: '3.1.0'
# ...
components:
schemas:
PatchList:
type: 'object'
properties:
# ...
pull_url:
title: 'Pull URL'
type:
- 'string'
- 'null'
format: 'uri'
maxLength: 255
# ...
If my server returns a response with pull_url
set to null
, then the call to openapi_core.validation.response.validators.ResponseValidator.validate
fails with the following traceback:
Traceback (most recent call last):
File "/dev/patchwork/patchwork/tests/api/test_relation.py", line 267, in test_remove_one_patch_from_relation_good
resp = self.client.patch(
File "/dev/patchwork/patchwork/tests/api/utils.py", line 241, in patch
validator.validate_data(
File "/dev/patchwork/patchwork/tests/api/validator.py", line 141, in validate_data
result.raise_for_errors()
File "/dev/openapi-core/openapi_core/validation/datatypes.py", line 12, in raise_for_errors
raise error
File "/dev/openapi-core/openapi_core/validation/response/validators.py", line 245, in validate
data = self._get_data(response, operation_response)
File "/dev/openapi-core/openapi_core/validation/response/validators.py", line 88, in _get_data
data = self._unmarshal(schema, casted)
File "/dev/openapi-core/openapi_core/validation/validators.py", line 76, in _unmarshal
return unmarshaller(value)
File "/dev/openapi-core/openapi_core/unmarshalling/schemas/unmarshallers.py", line 91, in __call__
return self.unmarshal(value)
File "/dev/openapi-core/openapi_core/unmarshalling/schemas/unmarshallers.py", line 434, in unmarshal
return unmarshaller.unmarshal(value)
File "/dev/openapi-core/openapi_core/unmarshalling/schemas/unmarshallers.py", line 316, in unmarshal
properties = self.format(value)
File "/dev/openapi-core/openapi_core/unmarshalling/schemas/unmarshallers.py", line 325, in format
return self._unmarshal_properties(formatted, schema_only=schema_only)
File "/dev/openapi-core/openapi_core/unmarshalling/schemas/unmarshallers.py", line 354, in _unmarshal_properties
all_of_properties = self._clone(all_of_schema).format(
File "/dev/openapi-core/openapi_core/unmarshalling/schemas/unmarshallers.py", line 325, in format
return self._unmarshal_properties(formatted, schema_only=schema_only)
File "/dev/openapi-core/openapi_core/unmarshalling/schemas/unmarshallers.py", line 373, in _unmarshal_properties
properties[prop_name] = self.unmarshallers_factory.create(
File "/dev/openapi-core/openapi_core/unmarshalling/schemas/unmarshallers.py", line 91, in __call__
return self.unmarshal(value)
File "/dev/openapi-core/openapi_core/unmarshalling/schemas/unmarshallers.py", line 433, in unmarshal
unmarshaller = self._get_best_unmarshaller(value)
File "/dev/openapi-core/openapi_core/unmarshalling/schemas/unmarshallers.py", line 430, in _get_best_unmarshaller
raise UnmarshallerError("Unmarshaller not found for type(s)")
openapi_core.unmarshalling.schemas.exceptions.UnmarshallerError: Unmarshaller not found for type(s)
If I comment out format
, things work as expected. I suspect it's attempting to apply a formatter for the null values. As far as I can tell, this should work though.