Python codegeneration for vk objects json schema (https://json-schema.org/)
Before launching the codegeneration you should setup json schema directory and imports in generated files.
Imports are configured in this way at config/config.yaml:
object_models_imports:
enum:
None
typing:
- Any
- List
- Optional
- Union
pydantic:
- BaseModel
which called in main.py file:
objects_imports: dict = CONFIG['object_models_imports']
Filepaths are configured in this way at config/config.yaml:
schema_objects_path:
vk_schema/objects.json
schema_methods_path:
vk_schema/methods.json
By default, files to parse comes from https://github.com/VKCOM/vk-api-schema but you can pass your own files, if their structure is the same as VK's.
Just
python __main__.py
Results of the codegeneration are stored in results/
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Each *_parser mostly is an independable parser with a simple interface. If you want to add your own parser make sure to make its interface like this:
parse_file(filepath, imports)
Objects parser consists of three types of models:
- Structure models - parse json schema into python classes with string representation. Those are stored in models/schema_objects
- Representation models - string representation for writing, are included in structure models.
- Titles - imports etc.
Please make sure to update tests as appropriate.