openapi-python-generator 2.0.1.dev1758361866__tar.gz → 2.0.1.dev1758565728__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {openapi_python_generator-2.0.1.dev1758361866 → openapi_python_generator-2.0.1.dev1758565728}/PKG-INFO +1 -1
- {openapi_python_generator-2.0.1.dev1758361866 → openapi_python_generator-2.0.1.dev1758565728}/pyproject.toml +1 -1
- {openapi_python_generator-2.0.1.dev1758361866 → openapi_python_generator-2.0.1.dev1758565728}/setup.py +1 -1
- {openapi_python_generator-2.0.1.dev1758361866 → openapi_python_generator-2.0.1.dev1758565728}/src/openapi_python_generator/language_converters/python/common.py +3 -1
- {openapi_python_generator-2.0.1.dev1758361866 → openapi_python_generator-2.0.1.dev1758565728}/src/openapi_python_generator/language_converters/python/jinja_config.py +5 -1
- {openapi_python_generator-2.0.1.dev1758361866 → openapi_python_generator-2.0.1.dev1758565728}/src/openapi_python_generator/language_converters/python/model_generator.py +1 -4
- openapi_python_generator-2.0.1.dev1758565728/src/openapi_python_generator/language_converters/python/templates/enum.jinja2 +11 -0
- {openapi_python_generator-2.0.1.dev1758361866 → openapi_python_generator-2.0.1.dev1758565728}/src/openapi_python_generator/language_converters/python/templates/models.jinja2 +1 -1
- {openapi_python_generator-2.0.1.dev1758361866 → openapi_python_generator-2.0.1.dev1758565728}/src/openapi_python_generator/language_converters/python/templates/models_pydantic_2.jinja2 +2 -2
- openapi_python_generator-2.0.1.dev1758361866/src/openapi_python_generator/language_converters/python/templates/enum.jinja2 +0 -9
- {openapi_python_generator-2.0.1.dev1758361866 → openapi_python_generator-2.0.1.dev1758565728}/LICENSE +0 -0
- {openapi_python_generator-2.0.1.dev1758361866 → openapi_python_generator-2.0.1.dev1758565728}/README.md +0 -0
- {openapi_python_generator-2.0.1.dev1758361866 → openapi_python_generator-2.0.1.dev1758565728}/src/openapi_python_generator/__init__.py +0 -0
- {openapi_python_generator-2.0.1.dev1758361866 → openapi_python_generator-2.0.1.dev1758565728}/src/openapi_python_generator/__main__.py +0 -0
- {openapi_python_generator-2.0.1.dev1758361866 → openapi_python_generator-2.0.1.dev1758565728}/src/openapi_python_generator/common.py +0 -0
- {openapi_python_generator-2.0.1.dev1758361866 → openapi_python_generator-2.0.1.dev1758565728}/src/openapi_python_generator/generate_data.py +0 -0
- {openapi_python_generator-2.0.1.dev1758361866 → openapi_python_generator-2.0.1.dev1758565728}/src/openapi_python_generator/language_converters/__init__.py +0 -0
- {openapi_python_generator-2.0.1.dev1758361866 → openapi_python_generator-2.0.1.dev1758565728}/src/openapi_python_generator/language_converters/python/__init__.py +0 -0
- {openapi_python_generator-2.0.1.dev1758361866 → openapi_python_generator-2.0.1.dev1758565728}/src/openapi_python_generator/language_converters/python/api_config_generator.py +0 -0
- {openapi_python_generator-2.0.1.dev1758361866 → openapi_python_generator-2.0.1.dev1758565728}/src/openapi_python_generator/language_converters/python/generator.py +0 -0
- {openapi_python_generator-2.0.1.dev1758361866 → openapi_python_generator-2.0.1.dev1758565728}/src/openapi_python_generator/language_converters/python/service_generator.py +0 -0
- {openapi_python_generator-2.0.1.dev1758361866 → openapi_python_generator-2.0.1.dev1758565728}/src/openapi_python_generator/language_converters/python/templates/aiohttp.jinja2 +0 -0
- {openapi_python_generator-2.0.1.dev1758361866 → openapi_python_generator-2.0.1.dev1758565728}/src/openapi_python_generator/language_converters/python/templates/apiconfig.jinja2 +0 -0
- {openapi_python_generator-2.0.1.dev1758361866 → openapi_python_generator-2.0.1.dev1758565728}/src/openapi_python_generator/language_converters/python/templates/apiconfig_pydantic_2.jinja2 +0 -0
- {openapi_python_generator-2.0.1.dev1758361866 → openapi_python_generator-2.0.1.dev1758565728}/src/openapi_python_generator/language_converters/python/templates/httpx.jinja2 +0 -0
- {openapi_python_generator-2.0.1.dev1758361866 → openapi_python_generator-2.0.1.dev1758565728}/src/openapi_python_generator/language_converters/python/templates/requests.jinja2 +0 -0
- {openapi_python_generator-2.0.1.dev1758361866 → openapi_python_generator-2.0.1.dev1758565728}/src/openapi_python_generator/language_converters/python/templates/service.jinja2 +0 -0
- {openapi_python_generator-2.0.1.dev1758361866 → openapi_python_generator-2.0.1.dev1758565728}/src/openapi_python_generator/models.py +0 -0
- {openapi_python_generator-2.0.1.dev1758361866 → openapi_python_generator-2.0.1.dev1758565728}/src/openapi_python_generator/parsers/__init__.py +0 -0
- {openapi_python_generator-2.0.1.dev1758361866 → openapi_python_generator-2.0.1.dev1758565728}/src/openapi_python_generator/parsers/openapi_30.py +0 -0
- {openapi_python_generator-2.0.1.dev1758361866 → openapi_python_generator-2.0.1.dev1758565728}/src/openapi_python_generator/parsers/openapi_31.py +0 -0
- {openapi_python_generator-2.0.1.dev1758361866 → openapi_python_generator-2.0.1.dev1758565728}/src/openapi_python_generator/py.typed +0 -0
- {openapi_python_generator-2.0.1.dev1758361866 → openapi_python_generator-2.0.1.dev1758565728}/src/openapi_python_generator/version_detector.py +0 -0
|
@@ -32,7 +32,7 @@ entry_points = \
|
|
|
32
32
|
|
|
33
33
|
setup_kwargs = {
|
|
34
34
|
'name': 'openapi-python-generator',
|
|
35
|
-
'version': '2.0.1.
|
|
35
|
+
'version': '2.0.1.dev1758565728',
|
|
36
36
|
'description': 'Openapi Python Generator',
|
|
37
37
|
'long_description': "# Openapi Python Generator\n\n[][pypi_]\n[][status]\n[][python version]\n[][license]\n\n[][documentation]\n[][tests]\n[][codecov]\n\n[][pre-commit]\n[][black]\n\n[pypi_]: https://pypi.org/project/openapi-python-generator/\n[status]: https://pypi.org/project/openapi-python-generator/\n[python version]: https://pypi.org/project/openapi-python-generator\n[documentation]: https://marcomuellner.github.io/openapi-python-generator/\n[tests]: https://github.com/MarcoMuellner/openapi-python-generator/actions?workflow=Tests\n[codecov]: https://app.codecov.io/gh/MarcoMuellner/openapi-python-generator\n[pre-commit]: https://github.com/pre-commit/pre-commit\n[black]: https://github.com/psf/black\n\n\n\n---\n__Documentation:__ [here][documentation]\n\n---\n\n## Features\n\n- __Ease of use__. Provide input, output and the library, and the generator will do the rest.\n- __Type safety and type hinting.__ __OpenAPI python generator__ makes heavy use of pydantic models to provide type-safe data structures.\n- __Support for multiple rest frameworks.__ __OpenAPI python generator__ currently supports the following:\n - [httpx](https://pypi.org/project/httpx/)\n - [requests](https://pypi.org/project/requests/)\n - [aiohttp](https://pypi.org/project/aiohttp/)\n- __Async and sync code generation support__, depending on the framework. It will automatically create both for frameworks that support both.\n- __Easily extendable using Jinja2 templates__. The code is designed to be easily extendable and should support even more languages and frameworks in the future.\n- __Fully tested__. Every generated code is automatically tested against the OpenAPI spec and we have 100% coverage.\n- __Usage as CLI or as library__.\n\n## Requirements\n\n- Python 3.7+\n\n## Installation\n\nYou can install _Openapi Python Generator_ via [pip] from [PyPI]:\n\n```console\n$ pip install openapi-python-generator\n```\n\n## Usage\n\nPlease see the [Quick start page] for details.\n\n## Roadmap\n\n- Support for all commonly used http libraries in the python ecosystem (~~requests~~, urllib, ...)\n- Support for multiple languages\n- Support for multiple authentication schemes\n- Support custom themes\n\n## Contributing\n\nContributions are very welcome.\nTo learn more, see the [Contributor Guide].\n\n## License\n\nDistributed under the terms of the [MIT license][license],\n_Openapi Python Generator_ is free and open source software.\n\n## Issues\n\nIf you encounter any problems,\nplease [file an issue] along with a detailed description.\n\n## Credits\n\nSpecial thanks to the peeps from [openapi-schema-pydantic](https://github.com/kuimono/openapi-schema-pydantic),\nwhich already did a lot of the legwork by providing a pydantic schema for the OpenAPI 3.0.0+ specification.\n\nThis project was generated from [@cjolowicz]'s [Hypermodern Python Cookiecutter] template.\n\n[@cjolowicz]: https://github.com/cjolowicz\n[pypi]: https://pypi.org/\n[hypermodern python cookiecutter]: https://github.com/cjolowicz/cookiecutter-hypermodern-python\n[file an issue]: https://github.com/MarcoMuellner/openapi-python-generator/issues\n[pip]: https://pip.pypa.io/\n\n<!-- github-only -->\n\n[license]: https://github.com/MarcoMuellner/openapi-python-generator/blob/main/LICENSE\n[contributor guide]: https://github.com/MarcoMuellner/openapi-python-generator/blob/main/CONTRIBUTING.md\n[Quick start page]: https://marcomuellner.github.io/openapi-python-generator/quick_start/\n",
|
|
38
38
|
'author': 'Marco Müllner',
|
|
@@ -49,8 +49,10 @@ def normalize_symbol(symbol: str) -> str:
|
|
|
49
49
|
:param symbol: name of the identifier
|
|
50
50
|
:return: normalized identifier name
|
|
51
51
|
"""
|
|
52
|
-
symbol = symbol.replace("-", "_")
|
|
52
|
+
symbol = symbol.replace("-", "_").replace(" ", "_")
|
|
53
53
|
normalized_symbol = _symbol_ascii_strip_re.sub("", symbol)
|
|
54
54
|
if normalized_symbol in keyword.kwlist:
|
|
55
55
|
normalized_symbol = normalized_symbol + "_"
|
|
56
|
+
if len(normalized_symbol) > 0 and normalized_symbol[0].isnumeric():
|
|
57
|
+
normalized_symbol = "_" + normalized_symbol
|
|
56
58
|
return normalized_symbol
|
|
@@ -16,7 +16,7 @@ TEMPLATE_PATH = Path(__file__).parent / "templates"
|
|
|
16
16
|
|
|
17
17
|
def create_jinja_env():
|
|
18
18
|
custom_template_path = common.get_custom_template_path()
|
|
19
|
-
|
|
19
|
+
environment = Environment(
|
|
20
20
|
loader=(
|
|
21
21
|
ChoiceLoader(
|
|
22
22
|
[
|
|
@@ -30,3 +30,7 @@ def create_jinja_env():
|
|
|
30
30
|
autoescape=True,
|
|
31
31
|
trim_blocks=True,
|
|
32
32
|
)
|
|
33
|
+
|
|
34
|
+
environment.filters["normalize_symbol"] = common.normalize_symbol
|
|
35
|
+
|
|
36
|
+
return environment
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import itertools
|
|
2
|
-
import re
|
|
3
2
|
from typing import List, Optional, Union
|
|
4
3
|
|
|
5
4
|
import click
|
|
@@ -414,10 +413,8 @@ def generate_models(
|
|
|
414
413
|
name = common.normalize_symbol(schema_name)
|
|
415
414
|
if schema_or_reference.enum is not None:
|
|
416
415
|
value_dict = schema_or_reference.model_dump()
|
|
417
|
-
regex = re.compile(r"[\s\/=\*\+]+")
|
|
418
416
|
value_dict["enum"] = [
|
|
419
|
-
|
|
420
|
-
for i in value_dict["enum"]
|
|
417
|
+
(common.normalize_symbol(str(i)).upper(), i) for i in value_dict["enum"]
|
|
421
418
|
]
|
|
422
419
|
m = Model(
|
|
423
420
|
file_name=name,
|
|
@@ -20,5 +20,5 @@ class {{ schema_name }}(BaseModel):
|
|
|
20
20
|
"""
|
|
21
21
|
{% for property in properties %}
|
|
22
22
|
|
|
23
|
-
{{ property.name |
|
|
23
|
+
{{ property.name | normalize_symbol }} : {{ property.type.converted_type | safe }} = Field(alias="{{ property.name }}" {% if not property.required %}, default = {{ property.default }} {% endif %})
|
|
24
24
|
{% endfor %}
|
|
@@ -24,5 +24,5 @@ class {{ schema_name }}(BaseModel):
|
|
|
24
24
|
}
|
|
25
25
|
{% for property in properties %}
|
|
26
26
|
|
|
27
|
-
{{ property.name |
|
|
28
|
-
{% endfor %}
|
|
27
|
+
{{ property.name | normalize_symbol }} : {{ property.type.converted_type | safe }} = Field(validation_alias="{{ property.name }}" {% if not property.required %}, default = {{ property.default }} {% endif %})
|
|
28
|
+
{% endfor %}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|