Skip to content

Support schema of a JSON object has no properties defined #70

@strainu

Description

@strainu

Is your feature request related to a problem? Please describe.
I'm trying to parse the following the following spec:

"MyType": {
  "type":"object",
  "properties":{
    "page":{
      "type":"integer",
      "format":"int32"
    },
    "data":{
      "type":"object"
    }
  }
}

This fails with:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\strainu\code\apliclient\datamodel.py", line 61, in get
    return self.api.call_queryAllNodeTypes()
  File "C:\Python39\lib\site-packages\openapi3\openapi.py", line 242, in __call__
    return self.operation(self.base_url, *args, security=self.security, **kwargs)
  File "C:\Python39\lib\site-packages\openapi3\paths.py", line 397, in request
    return expected_media.schema.model(result.json())
  File "C:\Python39\lib\site-packages\openapi3\schemas.py", line 157, in model
    return self.get_type()(data, self)
  File "C:\Python39\lib\site-packages\openapi3\schemas.py", line 297, in __init__
    setattr(self, k, object_schema.model(v))
  File "C:\Python39\lib\site-packages\openapi3\schemas.py", line 157, in model
    return self.get_type()(data, self)
  File "C:\Python39\lib\site-packages\openapi3\schemas.py", line 134, in get_type
    {"__slots__": self.properties.keys()},  # pylint: disable=attribute-defined-outside-init
AttributeError: 'NoneType' object has no attribute 'keys'

Fixing this immediate error exposes other follow-up errors.

Describe the solution you'd like
I would like to have support for such schemas, as they are standard-compliant. I am aware that this is considered a security risk

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions