Skip to content

Conversation

@osolmaz
Copy link
Contributor

@osolmaz osolmaz commented Aug 14, 2024

JSON Schemas are the single source of truth for page and block types. We implement auto-generated Pydantic models for manipulating JSON-DOC files in Python. See https://koxudaxi.github.io/datamodel-code-generator

The module path jsondoc.models contains said auto-generated models and any edits will be overwritten.

We make use of datamodel-code-generator conventions of customBasePath and customTypePath to rewire inheritance from base classes, so that blocks, rich text objects and file objects (e.g. for image block) can be deserialized elegantly. jsondoc.serialize contains logic that initializes Pydantic models from JSON-DOC files or dicts.

@osolmaz osolmaz changed the title Auto-generate Pydantic models from JSON Schemas and add converters Auto-generate Pydantic models from JSON Schemas Aug 21, 2024
@osolmaz osolmaz merged commit 9b93acf into main Aug 21, 2024
@osolmaz osolmaz deleted the add-converter-1 branch August 21, 2024 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant