openapi3 icon indicating copy to clipboard operation
openapi3 copied to clipboard

Support additionalProperties

Open philipcristiano opened this issue 5 years ago • 1 comments

When calling an API that returns more data than specified in the OpenAPI spec, openapi3 fails:

  File "[redacted]/lib/python3.7/site-packages/openapi3/openapi.py", line 189, in __call__
    **kwargs)
  File "[redacted]/lib/python3.7/site-packages/openapi3/paths.py", line 287, in request
    return expected_media.schema.model(result.json())
  File "[redacted]/lib/python3.7/site-packages/openapi3/schemas.py", line 113, in model
    return self.get_type()(data, self)
  File "[redacted]/lib/python3.7/site-packages/openapi3/schemas.py", line 173, in __init__
    setattr(self, k, object_schema.model(v))
  File "[redacted]/lib/python3.7/site-packages/openapi3/schemas.py", line 113, in model
    return self.get_type()(data, self)
  File "[redacted]/lib/python3.7/site-packages/openapi3/schemas.py", line 164, in __init__
    prop = schema.properties[k]
KeyError: 'dynamic-property'

The API I'm calling relies on additionalProperties: True in the spec to return an object with dynamic values that are not known at the time of spec generation.

philipcristiano avatar Jun 15 '20 17:06 philipcristiano

I tried to come up with a pull request in order to support additionalProperties: https://github.com/Dorthu/openapi3/pull/63

mephinet avatar Jan 11 '22 16:01 mephinet