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

server.jsonapi has no patternProperties #22

Closed
tpurcell90 opened this issue Jun 13, 2019 · 3 comments · Fixed by #83
Closed

server.jsonapi has no patternProperties #22

tpurcell90 opened this issue Jun 13, 2019 · 3 comments · Fixed by #83
Labels
schema Concerns the schema models

Comments

@tpurcell90
Copy link
Contributor

In the current version of pydanitc patternProperties can only be added inside sub-elements of properties. If that is fixed then remove items from optimade.server.models.jsonapi.Attributes and optimade.server.models.jsonapi.Realationships and make it match that new formalism.

Somewhere in the creation of the openapi.json file the patternProperties is lost (likely something is using an old version of pydantic that converts a Dict object to object if the key is not a string).

@tpurcell90 tpurcell90 mentioned this issue Jun 13, 2019
@tpurcell90
Copy link
Contributor Author

Merge request #41 removed the hack and added documentation that the disallowed types should not be used. At the moment this is not enforced.

@ltalirz ltalirz added the schema Concerns the schema models label Jun 22, 2019
@CasperWA
Copy link
Member

CasperWA commented Nov 14, 2019

Concerning relationships, this has been remedied by using BaseResource (see here) that only has id and type. Resource then subclasses this and adds attributes.
For relationships, they then only need to use BaseResource.

Concerning the restriction of attributes that was introduced by #24 here, this has since been removed, but it should probably be reintroduced, since Attributes now allow extra fields.
This may however be remedied by a pydantic validator, but it will not be reflected in the openapi.json (only through the doc-string, which may be fine?).

@CasperWA
Copy link
Member

It seems the root_validator needed for this task is not introduced until pydantic v1.0b1, and fastapi has only implemented pydantic up to v0.32.2 (and that's for the latest fastapi version, which we are still not using).
There is hope though, the root concept was introduced in v0.30 of pydantic, meaning if we update fastapi we may be able to use an older version of the root_validator concept.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
schema Concerns the schema models
Projects
None yet
3 participants