Skip to content
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

feat: Generate JSON schemas from Python data models [TECHART-244] #8

Draft
wants to merge 66 commits into
base: main
Choose a base branch
from

Conversation

Olaf-Wolf3D
Copy link
Collaborator

This PR is a proof of concept to generate the JSON schemas for asset validation from Python data models using pydantic.

Its goal is to have 1 source of truth that can be either used directly in Python or be exported to JSON schemas for consumption by other services.
It should theoretically even be possible to read compatible json instances generated by other services and validate them against the Python data model.

Checklist:

  • all schemas converted to models
  • unit tests
  • functional tests
  • github action
  • docs

@Olaf-Wolf3D Olaf-Wolf3D self-assigned this Jun 25, 2023
Olaf Haag and others added 23 commits July 10, 2023 10:46
update pre-commit hooks, setup guide, merge dev envs and set local path
json schema and Python errors share messages
so they can be re-used independently by other models
so it does not need to be disabled in each model
share error message between python and json schema by use of format()
use enum values to create model field types
should increase reusability of functions
Olaf Haag and others added 30 commits August 17, 2023 14:55
a pydantic model that asserts that there are no animations

Closes SRV-531
can write json schema to a default location using the caller's file name
use the new function instead of the logger to output schema to json

Task: SRV-531
use caller's name only as a backup
move GenerateAnimationJsonSchema to basemodel as SchemaNoTitleAndDefault
comment for a json schema to avoid confusion between object and keyword
populate models with the value of enums, rather than the raw enum
Move create_enum_class to separate module for re-use
dynamic enums instead of Literals, new model names, error messages

Closes SRV-528
instead of str use object as types to allow anything

Closes SRV-483
inject values from the ErrorDetails into a custom template message
co-authored by: @TechyDaniel
reusable field definitions
move extra functions and classes related to json schemas to schema_io
use moved functions that were moved earlier
errror messages, fields
Python <3.11 doesn't yet support it in the stdlib
it was blocking passing str to enum fields
remove plural from name
fix error messages
make wrap validators not override base
refactor for latest changes
json schema generation fixed

Task: SRV-528
need to change after common_texture renaming

Task: SRV-483
probably introduced through mypy update
Remove $id and $schema from subschemas
when not using hatch, the pre-commit install command needs to be more
make code blocks copyable in github UI
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.

3 participants