Update types to align with OpenAPI #480
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Use
conlist
instead ofTuple
sFixes #478
Due to the way pydantic converts types to JSON types, Tuples are not converted to OpenAPI-compliant JSON types.
Instead, conlist can be used to limit the length of the list and still comply with the desired effects in the actual use of the models.
Fields with constant values
Fixes #479
These fields were not listed as required, nor was it known what the constant value was from the OpenAPI.
This has been updated by adding the
pattern
attribute to Field, specifying the value wrapped in^
and$
.pattern
is used instead ofregex
, because there is no need to add an extra validator.These fields mainly include
type
, but alsoid
.Also, it seems from the pydantic documentation that the value of the
const
attribute of Field should be the same as the supplieddefault
value. So this has been updated for allconst
attribute values.Warning model better represented in OpenAPI
The
status
property is not part of the OPTIMADE Warning model, this has now been removed in the OpenAPI specification.Possible additions to this PR (or another PR):
Add OpenAPI validator to CII think we essentially already have this, in terms of the
openapi-spec-validator
, but it seems it's not good enough?Edit: This will be added in another PR (Validate OpenAPI specification in CI #481).
Swagger validation of the 70e8651 commit (it shows that all is good).