openapi-core icon indicating copy to clipboard operation
openapi-core copied to clipboard

Using required and allOf together

Open flixx opened this issue 3 years ago • 2 comments

Hello,

We are using openapi-core to validate Django Requests.

When I use this syntax:

SaveRequest:
  allOf:
    - $ref: "#/definitions/Dog"
    - required:
      - breed
      - name

I'm getting this error:

...
  File "/Users/felix/Library/Caches/pypoetry/virtualenvs/button3d-iF01JEUe-py3.8/lib/python3.8/site-packages/openapi_core/validation/request/validators.py", line 204, in _get_body
    body = self._unmarshal(media_type, casted)
  File "/Users/felix/Library/Caches/pypoetry/virtualenvs/button3d-iF01JEUe-py3.8/lib/python3.8/site-packages/openapi_core/validation/request/validators.py", line 255, in _unmarshal
    return super(RequestValidator, self)._unmarshal(
  File "/Users/felix/Library/Caches/pypoetry/virtualenvs/button3d-iF01JEUe-py3.8/lib/python3.8/site-packages/openapi_core/validation/validators.py", line 66, in _unmarshal
    return unmarshaller(value)
  File "/Users/felix/Library/Caches/pypoetry/virtualenvs/button3d-iF01JEUe-py3.8/lib/python3.8/site-packages/openapi_core/unmarshalling/schemas/unmarshallers.py", line 49, in __call__
    self.validate(value)
  File "/Users/felix/Library/Caches/pypoetry/virtualenvs/button3d-iF01JEUe-py3.8/lib/python3.8/site-packages/openapi_core/unmarshalling/schemas/unmarshallers.py", line 61, in validate
    errors = tuple(errors_iter)
  File "/Users/felix/Library/Caches/pypoetry/virtualenvs/button3d-iF01JEUe-py3.8/lib/python3.8/site-packages/jsonschema/validators.py", line 328, in iter_errors
    for error in errors:
  File "/Users/felix/Library/Caches/pypoetry/virtualenvs/button3d-iF01JEUe-py3.8/lib/python3.8/site-packages/jsonschema/_validators.py", line 315, in allOf
    for error in validator.descend(instance, subschema, schema_path=index):
  File "/Users/felix/Library/Caches/pypoetry/virtualenvs/button3d-iF01JEUe-py3.8/lib/python3.8/site-packages/jsonschema/validators.py", line 344, in descend
    for error in self.iter_errors(instance, schema):
  File "/Users/felix/Library/Caches/pypoetry/virtualenvs/button3d-iF01JEUe-py3.8/lib/python3.8/site-packages/jsonschema/validators.py", line 328, in iter_errors
    for error in errors:
  File "/Users/felix/Library/Caches/pypoetry/virtualenvs/button3d-iF01JEUe-py3.8/lib/python3.8/site-packages/openapi_schema_validator/_validators.py", line 43, in required
    prop_schema = schema['properties'][property]

According to this thread, it is a valid schema though: https://github.com/OAI/OpenAPI-Specification/issues/1608

Also related issue: https://github.com/p1c2u/openapi-core/issues/77

flixx avatar Jun 10 '21 09:06 flixx

Any news on this issue? Seems to still persist.

Also is there a workaround?

doemski avatar Apr 11 '23 14:04 doemski

@doemski please report separate issue with your details

p1c2u avatar Apr 11 '23 16:04 p1c2u