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
Fix field optonality inconsistency in schema #482
Conversation
…other SHOULD fields
Codecov Report
@@ Coverage Diff @@
## master #482 +/- ##
==========================================
- Coverage 91.67% 91.64% -0.04%
==========================================
Files 60 60
Lines 2848 2848
==========================================
- Hits 2611 2610 -1
- Misses 237 238 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
When you say pydantic, you mean our pydantic models, right? 😃
In my opinion, the approach should be that a SHOULD field that is supplied carries with it certain requirements. What I mean is, the length of the We should then make sure our pydantic model validations indeed hold true for these inter-field dependencies, while still being fine if a SHOULD field that is otherwise not required by another field, is left out of the structure. Edit: So all in all, I think we should make all SHOULD fields optional (but maybe not in this PR, but rather in #453). Fixing this inconsistency will make sure we hopefully get all fields into the right logical state by the end of #453. |
Pretend it always said that :)
I think this is our only option (no matter what we do with the schema) which will be a whole lot of fun to write and test... see my comments in the linked issue. Either way, this should be merged for now, and I think we should include it in the upstream PR so we are at least self-consistent at this stage. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ml-evs
As it stands, all SHOULD fields are non-optional in our pydantic models. Somehow this did not apply to
nperiodic_dimensions
andlattice_vectors
, so this PR fixes that.There is still an outstanding question about how we should handle these fields in pydantic and in OpenAPI. Are "SHOULD" fields "required"? It is impossible to validate our
StructureResource
automatically with pydantic with some fields missing, unless we made themOptional
and added conditionals to the pydantic validators.We might be able to get around this in the implementation validator by just ignoring documents that are not "full" of all the "SHOULD" fields (i.e. not returning an error), but then obviously their contents will not be well-checked.
I've written this description in this PR for posterity and will probably cross-post it to the appropriate issue.