Files
divkit/api_generator
feldspar e0efea91d0 Nested types fix
commit_hash:0e61cb86c4ecce349d6b76477d5f025a5896aa81
2026-02-26 13:21:52 +03:00
..
2026-02-26 13:21:52 +03:00
2026-02-26 13:21:52 +03:00
2022-09-16 15:06:12 +03:00
2022-09-16 15:06:12 +03:00

DivKit API Generator

The script takes a JSON schema at the input and generates the code of objects described in the schema based on it and the config.

Config format:

{
	"lang": "[kotlin|kotlinDsl|swift|typescript|python|documentation]",
	"header": "// Header of every generated file. Generated code. Do not modify.\nimport some.lib\nimport other.lib\n\n"
}

Commands

Build

Setup environment:

pip install -r dev_requirements.txt

Run generator:

python3 -m api_generator -c /config/file/name.json -s /path/to/schema -o /output/path [--checkhash] [--savehash]
./api_generator.sh /config/file/name.json /path/to/schema /output/path [--checkhash] [--savehash]
  • --checkhash Check the hash files in the output directory before generating
  • --savehash Save the hash files of the generator, config and schema to the output directory

Run tests:

python3 -m pytest

With ya make

Build:

ya make

Run generator:

./api_generator_script -c /config/file/name.json -s /path/to/schema -o /output/path [--checkhash] [--savehash]
  • --checkhash Check the hash files in the output directory before generating
  • --savehash Save the hash files of the generator, config and schema to the output directory

Run tests:

ya make -t