Console tool for generating API clients, data classes and validators. Written in Kotlin, produces Kotlin and Python code for various purposes (see "Available generators" below). For the input it takes OpenApi specification (JSON/YAML) or custom codegen schema (JSON).
The main goal of this project is to reduce integration costs between teams in multi-service environments.
- Write integration code in agile, fast-moving projects
- Use code generation in CI
- Track API changes and check them for backward compatibility on both sides (client/server)
- Build ETL pipelines with transparent interfaces
- Unify type declarations across languages
docker image pull registry.gitlab.com/atten0/ez-code-generator:master
Other image versions:
https://gitlab.com/atten0/ez-code-generator/container_registry
Download and extract archive into current dir:
wget -qO- https://github.com/atten/ez-code-generator/releases/download/v3.0.0/ez-codegen-3.0.0.zip | busybox unzip -
cd ez-codegen-3.0.0/bin/
chmod +x ez-codegen
Other versions lists:
ez-codegen [options] <files/directories/urls...>
Options:
* -t, --target
Target implementation
Possible Values: [KT_DATACLASS, KT_SERIALIZABLE_DATACLASS, KT_INTERFACE, PY_DJANGO_MODEL, PY_API_CLIENT, PY_API_ASYNC_CLIENT, PY_AMQP_BLOCKING_CLIENT, PY_AMQP_GEVENT_CLIENT, PY_MARSHMALLOW_DATACLASS, PY_DATACLASS]
-n, --name
Generated class name (inferred from input files if not specified)
Default: <empty string>
--include-url-path
Include only paths containing given strings
Default: []
--exclude-url-path
Do not include paths containing given strings
Default: []
-p, --prefixed
If enabled, add prefix to all fields
Default: false
--help
Show help usage and exit
--version, -v
Display version and exit
Runs generator in docker container, reads OpenApi spec from URL and saves output to file.
docker run --rm registry.gitlab.com/atten0/ez-code-generator:master \
https://gitlab.com/atten0/ez-code-generator/-/raw/master/src/test/resources/input/openApi.json \
-t PY_API_CLIENT \
> client_generated.py
Target | Language/Framework | Serialization | Dependencies | Example output | Coverage |
---|---|---|---|---|---|
KT_DATACLASS | Kotlin | kotlinx.serialization | entitiesOutput.kt | ||
KT_SERIALIZABLE_DATACLASS | Kotlin | Jackson | entitiesOutputJacksonEnabled.kt | ||
PY_API_CLIENT | Python (3.9 - 3.12) | Marshmallow | requirements.txt | endpointsOutput.py | |
PY_API_ASYNC_CLIENT | Python asyncio (3.9 - 3.12) | Marshmallow | requirements.txt | endpointsOutput.py | |
PY_DATACLASS | Python (3.9 - 3.12) | Dataclass | - | entitiesOutput.py | |
PY_MARSHMALLOW_DATACLASS | Python (3.9 - 3.12) | Marshmallow | requirements.txt | entitiesOutput.py | |
PY_DJANGO_MODEL | Python (3.9 - 3.12) + Django | - | requirements.txt | entitiesOutput.py | |
PY_AMQP_BLOCKING_CLIENT | Python3 | Marshmallow | endpointsOutput.py | ||
PY_AMQP_GEVENT_CLIENT | Python3 + Gevent | Marshmallow | endpointsOutput.py |
For usage questions, feature proposals and bug reports: github issues page.
For other matters: author's profile with contacts.