internetarchive / internetarchive/openlibrary
Import API should validate input
- Dominant language
- Python
- Stars
- 6.7k
- Forks
- 2k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 138
Description
Want the import api to validate provided JSON, and reject any invalid documents.
### Plan
One of the issues: currently the only json schema we have for this API resides in openlibrary-client: https://github.com/internetarchive/openlibrary-client/blob/99e600136f033a034690f947e3f09d930455c2c9/olclient/schemata/import.schema.json . We would like to avoid duplicating this if possible. Note longer term, these json schema files should be auto-generated by the server from the infogami type, since that is the actual ground truth. (eg https://openlibrary.org/type/work). Note this doesn't apply to the import api (?).
- [x] #5781 Determine validation library to use + integrate
- [x] Add identifiers field to import schema on openlibrary-client (https://github.com/internetarchive/openlibrary-client/pull/272)
- [ ] Generate the pydantic class from the schema file
- https://github.com/koxudaxi/datamodel-code-generator/
- [ ] Import json schema from olclient into OL
- This is a little awkward, but the only we can import this right now to avoid duplicating.
- [ ] Add a test case to ensure generated pydantic classes are up-to-date
- Same model as the `solr_types_generator.py` which generates a `SolrDocument` class
### Additional context
### Stakeholders
@hornc @cdrini @mekarpeles @jimchamp
Contributor guide
Assessment
This issue has not been assessed yet.