Name | ez-code-generator JSON |
Version |
3.2.2
JSON |
| download |
home_page | None |
Summary | Console tool for generating API clients, data classes and validators |
upload_time | 2025-07-20 11:29:37 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | None |
keywords |
codegen
swagger
openapi
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Easy Code Generator
[](https://gitlab.com/atten0/ez-code-generator/-/pipelines)
[](http://www.jacoco.org/jacoco)
[](https://pypi.org/project/ez-code-generator)
Console tool for generating API clients, data classes and validators. Written in Kotlin, produces Kotlin and Python code. For the input it takes OpenApi document (JSON/YAML, v2.0 ‒ v3.2.2) or custom codegen schema (JSON).
The main goal of this project is to reduce integration costs between teams in multi-service environments.
### Example
<table>
<tr>
<td> OpenAPI source YAML </td>
<td>
```yaml
definitions:
BasicDto:
type: object
properties:
a:
title: Some integer
description: Field description
type: integer
maximum: 255
minimum: 0
b:
title: Timestamp
type: string
format: date-time
c:
title: Some enum
type: string
enum:
- variant1
- variant2
- variant3
default: variant1
required:
- a
```
</td>
</tr>
<tr>
<td> Python generated dataclass </td>
<td>
```python
@dataclass
class BasicDto:
# Field description
a: int = field()
b: t.Optional[datetime] = None
c: t.Optional[str] = "variant1"
```
</td>
</tr>
<tr>
<td> Kotlin generated classes </td>
<td>
```kotlin
@Serializable
enum class SomeEnum(val value: String) {
@SerialName("variant1")
VARIANT_1("variant1"),
@SerialName("variant2")
VARIANT_2("variant2"),
@SerialName("variant3")
VARIANT_3("variant3"),
}
@Serializable
data class BasicDto(
// Field description
val a: Int,
@Contextual
val b: Instant? = null,
val c: SomeEnum? = SomeEnum.VARIANT_1,
)
```
</td>
</tr>
</table>
> More examples: section [Available generators](#available-generators) below
### Features
- Several python frameworks support (asyncio, django, pure dataclass etc);
- Schema validation, logging, error handling, retries and sessions within generated client out-of-the-box;
- Streamed dump/load (ijson);
- Kotlin experimental support.
### Key differences
*ez-code-generator* is similar to [openapi-generator](https://github.com/openapitools/openapi-generator) except a major aspect: **a single output file instead of a package**.
It is meant to be straightforward and concise. No extra configuration options, no tricky preparations before use.
Just install dependencies, import generated client class and instantiate it. Then call API methods which take and return generated DTOs:
```python
from client_generated import AllConstantsCollection as consts
from client_generated import AllDataclassesCollection as dto
from client_generated import RestApi
client = RestApi('https://example.com/v1/')
item = client.get_item(a=10)
# item = BasicDto(a=10, b=None, c="variant1")
```
### Common use cases
- 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.
## Install
### Docker image
```
docker image pull registry.gitlab.com/atten0/ez-code-generator:master
```
[Other image versions](https://gitlab.com/atten0/ez-code-generator/container_registry/1706585)
### JAR
Requires: Java 11
Download and extract archive into current dir:
```shell
wget -qO- https://github.com/atten/ez-code-generator/releases/download/v3.2.2/ez-codegen-3.2.2.zip | busybox unzip -
cd ez-codegen-3.2.2/bin/
chmod +x ez-codegen
```
Other versions: [Gitlab](https://gitlab.com/atten0/ez-code-generator/-/jobs/artifacts/master/browse/build/distributions/?job=publish-archive) | [Github](https://github.com/atten/ez-code-generator/releases)
### Python package
Requires: Java 11, Python3
```shell
pip install ez-code-generator==3.2.2
```
Other versions: [PYPI](https://pypi.org/project/ez-code-generator/#history)
### Build from source
```shell
make build
```
## Usage
ez-codegen [options] <files/directories/urls...>
Using python package:
python -m 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
-k, --insecure
Disable HTTPS certificates validation
Default: false
--help
Show help usage and exit
--version, -v
Display version and exit
## Basic guide
### Script for python API client generation from OpenApi
Runs generator in docker container, reads OpenApi spec from URL and saves output to file.
```shell
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
```
> Result: [client_generated.py](src/test/resources/org/codegen/generators/PyApiClientGenerator/endpointsOutput.py).
Usage examples: [test_clent.py](generatedCodeTests/PyApiClientGenerator/test_clent.py)
## Available generators
| Target | Language/Framework | Serialization | Dependencies | Example output | Coverage |
|---------------------------|------------------------------|-----------------------|-----------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| KT_DATACLASS | Kotlin | kotlinx.serialization | | [entitiesOutput.kt](src/test/resources/org/codegen/generators/KtSerializableDataclassGenerator/entitiesOutput.kt) | [](https://gitlab.com/atten0/ez-code-generator/-/jobs/artifacts/master/browse/generatedCodeTests/KtSerializableDataclassGenerator/htmlcov?job=run-tests-KtSerializableDataclassGenerator) |
| KT_SERIALIZABLE_DATACLASS | Kotlin | Jackson | | [entitiesOutputJacksonEnabled.kt](src/test/resources/org/codegen/generators/KtSerializableDataclassGenerator/entitiesOutputJacksonEnabled.kt) | [](https://gitlab.com/atten0/ez-code-generator/-/jobs/artifacts/master/browse/generatedCodeTests/KtSerializableDataclassGenerator/htmlcov?job=run-tests-KtSerializableDataclassGenerator) |
| PY_API_CLIENT | Python (3.9 - 3.12) | Marshmallow | [requirements.txt](generatedCodeTests/PyApiClientGenerator/requirements.txt) | [endpointsOutput.py](src/test/resources/org/codegen/generators/PyApiClientGenerator/endpointsOutput.py) | [](https://gitlab.com/atten0/ez-code-generator/-/jobs/artifacts/master/browse/generatedCodeTests/PyApiClientGenerator/htmlcov?job=run-tests-PyApiClientGenerator) |
| PY_API_ASYNC_CLIENT | Python asyncio (3.9 - 3.12) | Marshmallow | [requirements.txt](generatedCodeTests/PyApiAsyncClientGenerator/requirements.txt) | [endpointsOutput.py](src/test/resources/org/codegen/generators/PyApiAsyncClientGenerator/endpointsOutput.py) | [](https://gitlab.com/atten0/ez-code-generator/-/jobs/artifacts/master/browse/generatedCodeTests/PyApiAsyncClientGenerator/htmlcov?job=run-tests-PyApiAsyncClientGenerator) |
| PY_DATACLASS | Python (3.9 - 3.12) | Dataclass | - | [entitiesOutput.py](src/test/resources/org/codegen/generators/PyDataclassGenerator/entitiesOutput.py) | [](https://gitlab.com/atten0/ez-code-generator/-/jobs/artifacts/master/browse/generatedCodeTests/PyDataclassGenerator/htmlcov?job=run-tests-PyDataclassGenerator) |
| PY_MARSHMALLOW_DATACLASS | Python (3.9 - 3.12) | Marshmallow | [requirements.txt](generatedCodeTests/PyMarshmallowDataclassGenerator/requirements.txt) | [entitiesOutput.py](src/test/resources/org/codegen/generators/PyMarshmallowDataclassGenerator/entitiesOutput.py) | [](https://gitlab.com/atten0/ez-code-generator/-/jobs/artifacts/master/browse/generatedCodeTests/PyMarshmallowDataclassGenerator/htmlcov?job=run-tests-PyMarshmallowDataclassGenerator) |
| PY_DJANGO_MODEL | Python (3.9 - 3.12) + Django | - | [requirements.txt](generatedCodeTests/PyDjangoModelGenerator/requirements.txt) | [entitiesOutput.py](src/test/resources/org/codegen/generators/PyDjangoModelGenerator/entitiesOutput.py) | [](https://gitlab.com/atten0/ez-code-generator/-/jobs/artifacts/master/browse/generatedCodeTests/PyDjangoModelGenerator/htmlcov?job=run-tests-PyDjangoModelGenerator) |
| PY_AMQP_BLOCKING_CLIENT | Python3 | Marshmallow | | [endpointsOutput.py](src/test/resources/org/codegen/generators/PyAmqpBlockingClientGenerator/endpointsOutput.py) | [](https://gitlab.com/atten0/ez-code-generator/-/jobs/artifacts/master/browse/generatedCodeTests/PyAmqpBlockingClientGenerator/htmlcov?job=run-tests-PyAmqpBlockingClientGenerator) |
| PY_AMQP_GEVENT_CLIENT | Python3 + Gevent | Marshmallow | | [endpointsOutput.py](src/test/resources/org/codegen/generators/PyAmqpGeventClientGenerator/endpointsOutput.py) | [](https://gitlab.com/atten0/ez-code-generator/-/jobs/artifacts/master/browse/generatedCodeTests/PyAmqpGeventClientGenerator/htmlcov?job=run-tests-PyAmqpGeventClientGenerator) |
## Support and feedback
For usage questions, feature proposals and bug reports: [github issues page](https://github.com/atten/ez-code-generator/issues).
For other matters: [author's profile with contacts](https://github.com/atten).
Raw data
{
"_id": null,
"home_page": null,
"name": "ez-code-generator",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "codegen, swagger, openapi",
"author": null,
"author_email": "Artem Vasilev <art@force.fm>",
"download_url": null,
"platform": null,
"description": "# Easy Code Generator\n\n[](https://gitlab.com/atten0/ez-code-generator/-/pipelines)\n[](http://www.jacoco.org/jacoco)\n[](https://pypi.org/project/ez-code-generator)\n\nConsole tool for generating API clients, data classes and validators. Written in Kotlin, produces Kotlin and Python code. For the input it takes OpenApi document (JSON/YAML, v2.0 \u2012 v3.2.2) or custom codegen schema (JSON).\n\nThe main goal of this project is to reduce integration costs between teams in multi-service environments.\n\n### Example\n\n<table>\n<tr>\n<td> OpenAPI source YAML </td>\n<td>\n\n```yaml\ndefinitions:\n BasicDto:\n type: object\n properties:\n a:\n title: Some integer\n description: Field description\n type: integer\n maximum: 255\n minimum: 0\n b:\n title: Timestamp\n type: string\n format: date-time\n c:\n title: Some enum\n type: string\n enum:\n - variant1\n - variant2\n - variant3\n default: variant1\n required:\n - a\n```\n\n</td>\n</tr>\n<tr>\n<td> Python generated dataclass </td>\n<td>\n\n```python\n@dataclass\nclass BasicDto:\n # Field description\n a: int = field()\n b: t.Optional[datetime] = None\n c: t.Optional[str] = \"variant1\" \n```\n\n</td>\n</tr>\n<tr>\n<td> Kotlin generated classes </td>\n<td>\n\n```kotlin\n@Serializable\nenum class SomeEnum(val value: String) {\n @SerialName(\"variant1\")\n VARIANT_1(\"variant1\"),\n @SerialName(\"variant2\")\n VARIANT_2(\"variant2\"),\n @SerialName(\"variant3\")\n VARIANT_3(\"variant3\"),\n}\n\n@Serializable\ndata class BasicDto(\n // Field description\n val a: Int,\n @Contextual\n val b: Instant? = null,\n val c: SomeEnum? = SomeEnum.VARIANT_1,\n)\n```\n\n</td>\n</tr>\n</table>\n\n> More examples: section [Available generators](#available-generators) below\n\n### Features\n\n- Several python frameworks support (asyncio, django, pure dataclass etc);\n- Schema validation, logging, error handling, retries and sessions within generated client out-of-the-box;\n- Streamed dump/load (ijson);\n- Kotlin experimental support.\n\n### Key differences\n\n*ez-code-generator* is similar to [openapi-generator](https://github.com/openapitools/openapi-generator) except a major aspect: **a single output file instead of a package**. \nIt is meant to be straightforward and concise. No extra configuration options, no tricky preparations before use.\nJust install dependencies, import generated client class and instantiate it. Then call API methods which take and return generated DTOs:\n\n```python\nfrom client_generated import AllConstantsCollection as consts\nfrom client_generated import AllDataclassesCollection as dto\nfrom client_generated import RestApi\n\nclient = RestApi('https://example.com/v1/')\nitem = client.get_item(a=10)\n\n# item = BasicDto(a=10, b=None, c=\"variant1\")\n```\n\n### Common use cases\n\n- Write integration code in agile, fast-moving projects;\n- Use code generation in CI;\n- Track API changes and check them for backward compatibility on both sides (client/server);\n- Build ETL pipelines with transparent interfaces;\n- Unify type declarations across languages.\n\n## Install\n\n### Docker image\n\n```\ndocker image pull registry.gitlab.com/atten0/ez-code-generator:master\n```\n\n[Other image versions](https://gitlab.com/atten0/ez-code-generator/container_registry/1706585)\n\n### JAR\n\nRequires: Java 11\n\nDownload and extract archive into current dir:\n\n```shell\nwget -qO- https://github.com/atten/ez-code-generator/releases/download/v3.2.2/ez-codegen-3.2.2.zip | busybox unzip -\ncd ez-codegen-3.2.2/bin/\nchmod +x ez-codegen\n```\n\nOther versions: [Gitlab](https://gitlab.com/atten0/ez-code-generator/-/jobs/artifacts/master/browse/build/distributions/?job=publish-archive) | [Github](https://github.com/atten/ez-code-generator/releases)\n\n### Python package\n\nRequires: Java 11, Python3\n\n```shell\npip install ez-code-generator==3.2.2\n```\n\nOther versions: [PYPI](https://pypi.org/project/ez-code-generator/#history)\n\n### Build from source\n\n```shell\nmake build\n```\n\n## Usage\n\n ez-codegen [options] <files/directories/urls...>\n\nUsing python package:\n\n python -m ez-codegen [options] <files/directories/urls...>\n\nOptions:\n\n * -t, --target\n Target implementation\n 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\n -n, --name\n Generated class name (inferred from input files if not specified)\n Default: <empty string>\n\n --include-url-path\n Include only paths containing given strings\n Default: []\n\n --exclude-url-path\n Do not include paths containing given strings\n Default: []\n\n -p, --prefixed\n If enabled, add prefix to all fields\n Default: false\n\n -k, --insecure\n Disable HTTPS certificates validation\n Default: false\n\n --help\n Show help usage and exit\n\n --version, -v\n Display version and exit\n\n## Basic guide\n\n### Script for python API client generation from OpenApi\n\nRuns generator in docker container, reads OpenApi spec from URL and saves output to file.\n\n```shell\ndocker run --rm registry.gitlab.com/atten0/ez-code-generator:master \\\n https://gitlab.com/atten0/ez-code-generator/-/raw/master/src/test/resources/input/openApi.json \\\n -t PY_API_CLIENT \\\n > client_generated.py\n```\n\n> Result: [client_generated.py](src/test/resources/org/codegen/generators/PyApiClientGenerator/endpointsOutput.py).\n\nUsage examples: [test_clent.py](generatedCodeTests/PyApiClientGenerator/test_clent.py)\n\n## Available generators\n\n| Target | Language/Framework | Serialization | Dependencies | Example output | Coverage |\n|---------------------------|------------------------------|-----------------------|-----------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| KT_DATACLASS | Kotlin | kotlinx.serialization | | [entitiesOutput.kt](src/test/resources/org/codegen/generators/KtSerializableDataclassGenerator/entitiesOutput.kt) | [](https://gitlab.com/atten0/ez-code-generator/-/jobs/artifacts/master/browse/generatedCodeTests/KtSerializableDataclassGenerator/htmlcov?job=run-tests-KtSerializableDataclassGenerator) |\n| KT_SERIALIZABLE_DATACLASS | Kotlin | Jackson | | [entitiesOutputJacksonEnabled.kt](src/test/resources/org/codegen/generators/KtSerializableDataclassGenerator/entitiesOutputJacksonEnabled.kt) | [](https://gitlab.com/atten0/ez-code-generator/-/jobs/artifacts/master/browse/generatedCodeTests/KtSerializableDataclassGenerator/htmlcov?job=run-tests-KtSerializableDataclassGenerator) |\n| PY_API_CLIENT | Python (3.9 - 3.12) | Marshmallow | [requirements.txt](generatedCodeTests/PyApiClientGenerator/requirements.txt) | [endpointsOutput.py](src/test/resources/org/codegen/generators/PyApiClientGenerator/endpointsOutput.py) | [](https://gitlab.com/atten0/ez-code-generator/-/jobs/artifacts/master/browse/generatedCodeTests/PyApiClientGenerator/htmlcov?job=run-tests-PyApiClientGenerator) |\n| PY_API_ASYNC_CLIENT | Python asyncio (3.9 - 3.12) | Marshmallow | [requirements.txt](generatedCodeTests/PyApiAsyncClientGenerator/requirements.txt) | [endpointsOutput.py](src/test/resources/org/codegen/generators/PyApiAsyncClientGenerator/endpointsOutput.py) | [](https://gitlab.com/atten0/ez-code-generator/-/jobs/artifacts/master/browse/generatedCodeTests/PyApiAsyncClientGenerator/htmlcov?job=run-tests-PyApiAsyncClientGenerator) |\n| PY_DATACLASS | Python (3.9 - 3.12) | Dataclass | - | [entitiesOutput.py](src/test/resources/org/codegen/generators/PyDataclassGenerator/entitiesOutput.py) | [](https://gitlab.com/atten0/ez-code-generator/-/jobs/artifacts/master/browse/generatedCodeTests/PyDataclassGenerator/htmlcov?job=run-tests-PyDataclassGenerator) |\n| PY_MARSHMALLOW_DATACLASS | Python (3.9 - 3.12) | Marshmallow | [requirements.txt](generatedCodeTests/PyMarshmallowDataclassGenerator/requirements.txt) | [entitiesOutput.py](src/test/resources/org/codegen/generators/PyMarshmallowDataclassGenerator/entitiesOutput.py) | [](https://gitlab.com/atten0/ez-code-generator/-/jobs/artifacts/master/browse/generatedCodeTests/PyMarshmallowDataclassGenerator/htmlcov?job=run-tests-PyMarshmallowDataclassGenerator) |\n| PY_DJANGO_MODEL | Python (3.9 - 3.12) + Django | - | [requirements.txt](generatedCodeTests/PyDjangoModelGenerator/requirements.txt) | [entitiesOutput.py](src/test/resources/org/codegen/generators/PyDjangoModelGenerator/entitiesOutput.py) | [](https://gitlab.com/atten0/ez-code-generator/-/jobs/artifacts/master/browse/generatedCodeTests/PyDjangoModelGenerator/htmlcov?job=run-tests-PyDjangoModelGenerator) |\n| PY_AMQP_BLOCKING_CLIENT | Python3 | Marshmallow | | [endpointsOutput.py](src/test/resources/org/codegen/generators/PyAmqpBlockingClientGenerator/endpointsOutput.py) | [](https://gitlab.com/atten0/ez-code-generator/-/jobs/artifacts/master/browse/generatedCodeTests/PyAmqpBlockingClientGenerator/htmlcov?job=run-tests-PyAmqpBlockingClientGenerator) |\n| PY_AMQP_GEVENT_CLIENT | Python3 + Gevent | Marshmallow | | [endpointsOutput.py](src/test/resources/org/codegen/generators/PyAmqpGeventClientGenerator/endpointsOutput.py) | [](https://gitlab.com/atten0/ez-code-generator/-/jobs/artifacts/master/browse/generatedCodeTests/PyAmqpGeventClientGenerator/htmlcov?job=run-tests-PyAmqpGeventClientGenerator) |\n\n## Support and feedback\n\nFor usage questions, feature proposals and bug reports: [github issues page](https://github.com/atten/ez-code-generator/issues).\n\nFor other matters: [author's profile with contacts](https://github.com/atten).\n",
"bugtrack_url": null,
"license": null,
"summary": "Console tool for generating API clients, data classes and validators",
"version": "3.2.2",
"project_urls": {
"repository": "https://github.com/atten/ez-code-generator"
},
"split_keywords": [
"codegen",
" swagger",
" openapi"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "f43e5131711cac100b7bea547bf15f6aecd57c958825317a733aea245fc0045b",
"md5": "1eb91caac9dcdd02ea2743bc711e4117",
"sha256": "0a289c2a74fd6afc9b66de60607946430f8a6c6a3dd577be045a2ccea29a605c"
},
"downloads": -1,
"filename": "ez_code_generator-3.2.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1eb91caac9dcdd02ea2743bc711e4117",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 7003050,
"upload_time": "2025-07-20T11:29:37",
"upload_time_iso_8601": "2025-07-20T11:29:37.604633Z",
"url": "https://files.pythonhosted.org/packages/f4/3e/5131711cac100b7bea547bf15f6aecd57c958825317a733aea245fc0045b/ez_code_generator-3.2.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-20 11:29:37",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "atten",
"github_project": "ez-code-generator",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "ez-code-generator"
}