Closed dylanmcreynolds closed 4 years ago
Related to an old issue, https://github.com/bluesky/event-model/issues/76. Validation could be stricter across the board by leveraging jsonschema to a fuller extent and further by enforcing anything that cannot be expressed in jsonschema in Python code in the document composition function.
We have been using https://pydantic-docs.helpmanual.io/ for this. You can express your json schema in terms of Python dataclass-style classes, which can be exported to a json schema, and add custom validators in Python for the more difficult cases that will be picked up when you instantiate the objects.
Thanks, @thomascobb. That seems like a good direction to go in here.
We just started using pydantic in a web project (because of FastAPI). So far I'm a fan, and have been considering embedding it deeper into the framework than just the REST layer. It is certainly much easier to read than jsonschema, at least for easy cases.
Several parts of the projection schema a mutually exclusive. For example, you can either have type=computed or a type=linked. Currently, the schema allows for linked types with computed attributes. It would be nice if the schema provided stronger validation for this case. There might be additional opportunities for stronger validation.