MetOffice / MetOffice/edr_server
Ensure serialisation correctly respects required and nullable fields
- Dominant language
- Python
- Stars
- 1
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
The [EDR OpenAPI schema](https://github.com/opengeospatial/ogcapi-environmental-data-retrieval/tree/master/standard/openapi) identifies some elements as required and/or nullable
We haven't been particularly rigorous in adhering to these restrictions in our initial implementation.
The implications for the `core.models` data models:
* it should be possible to set nullable values to `None`
* values for optional fields should default to `None` if not explicitly set
* values that are not allowed to be nullable should be always set, either by an explicit argument or sensible default
The implications for serialisation are:
* when encoding nullable fields (both optional and required), `None` values are serialised as JSON `null` values
* when encoding non-nullable, optional fields, the field is omitted from the output if the value is `None`
* non-nullable, required fields set to `None` would be an error, and ought not to be possible if our `core.models` are correctly implemented
I believe the possible options are something like
| | nullable=False | nullable=True |
|-|-----------------|-----------------|
| required=True | `None` **not allowed** in data models; **always included** in serialisation | `None` **allowed** in data models; **always included** in serialisation |
| required=False| `None` **allowed** in data models; **not included** in serialisation if *set to `None`* | `None` **allowed** in data models; Element **omitted** from serialisation if *set to `None`* |
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by comparing the EDR OpenAPI schema in standard/openapi with the core.models data models and their serialization code. Implement the required and nullable rules described in the issue, then verify that model defaults and serialized JSON include, omit, or emit null values as specified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100