Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
strainu opened this issue Feb 4, 2022 · 1 comment · Fixed by #71
Closed

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

strainu opened this issue Feb 4, 2022 · 1 comment · Fixed by #71
Assignees

Comments

@strainu
Copy link

strainu commented Feb 4, 2022

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

@Dorthu Dorthu self-assigned this Feb 4, 2022
@Dorthu
Copy link
Owner

Dorthu commented Feb 4, 2022

I agree that this should be supported, and seems related the discussion on additionalProperties in #63.

Dorthu added a commit that referenced this issue Feb 4, 2022
Dorthu added a commit that referenced this issue Feb 4, 2022
A Schema defined as:

```
example:
  type: object
```

should generate a Model named `example` with no `__slots__`.

This change allows generation of a model as described, and
closes #70.
@Dorthu Dorthu closed this as completed in #71 Feb 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants