ab-openapi-python-generator 2.2.0__py3-none-any.whl → 2.2.2__py3-none-any.whl
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.
- ab_openapi_python_generator/generate_data.py +1 -1
- ab_openapi_python_generator/language_converters/python/client_generator.py +20 -26
- ab_openapi_python_generator/language_converters/python/jinja_config.py +2 -1
- ab_openapi_python_generator/language_converters/python/model_generator.py +1 -1
- ab_openapi_python_generator/language_converters/python/templates/async_client_httpx_pydantic_2.jinja2 +5 -5
- ab_openapi_python_generator/language_converters/python/templates/sync_client_httpx_pydantic_2.jinja2 +5 -5
- ab_openapi_python_generator/models.py +0 -15
- {ab_openapi_python_generator-2.2.0.dist-info → ab_openapi_python_generator-2.2.2.dist-info}/METADATA +1 -1
- {ab_openapi_python_generator-2.2.0.dist-info → ab_openapi_python_generator-2.2.2.dist-info}/RECORD +12 -12
- {ab_openapi_python_generator-2.2.0.dist-info → ab_openapi_python_generator-2.2.2.dist-info}/WHEEL +0 -0
- {ab_openapi_python_generator-2.2.0.dist-info → ab_openapi_python_generator-2.2.2.dist-info}/entry_points.txt +0 -0
- {ab_openapi_python_generator-2.2.0.dist-info → ab_openapi_python_generator-2.2.2.dist-info}/licenses/LICENSE +0 -0
|
@@ -125,7 +125,7 @@ def write_data(data: ConversionResult, output: Union[str, Path], formatter: Form
|
|
|
125
125
|
Creates:
|
|
126
126
|
- models/ (and models/__init__.py)
|
|
127
127
|
- clients/ (and clients/__init__.py)
|
|
128
|
-
- exceptions
|
|
128
|
+
- exceptions (package root/__init__.py)
|
|
129
129
|
- __init__.py (package root)
|
|
130
130
|
"""
|
|
131
131
|
out = Path(output)
|
|
@@ -363,34 +363,28 @@ def generate_clients(
|
|
|
363
363
|
def _generate_service_operation(
|
|
364
364
|
op: Operation, path_obj: PathItem, path_name: str, http_operation: str, async_type: bool
|
|
365
365
|
) -> ServiceOperation:
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
if
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
op.parameters.append(p) # type: ignore
|
|
381
|
-
except Exception:
|
|
382
|
-
pass
|
|
366
|
+
path_level_params = []
|
|
367
|
+
if hasattr(path_obj, "parameters") and path_obj.parameters is not None:
|
|
368
|
+
path_level_params = [p for p in path_obj.parameters if p is not None]
|
|
369
|
+
if path_level_params:
|
|
370
|
+
existing_names = set()
|
|
371
|
+
if op.parameters is not None:
|
|
372
|
+
for p in op.parameters:
|
|
373
|
+
if isinstance(p, (Parameter30, Parameter31)):
|
|
374
|
+
existing_names.add(p.name)
|
|
375
|
+
for p in path_level_params:
|
|
376
|
+
if isinstance(p, (Parameter30, Parameter31)) and p.name not in existing_names:
|
|
377
|
+
if op.parameters is None:
|
|
378
|
+
op.parameters = [] # type: ignore
|
|
379
|
+
op.parameters.append(p) # type: ignore
|
|
383
380
|
|
|
384
381
|
params = generate_params(op)
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
params = f"{norm_ph}: Any, " + params
|
|
392
|
-
except Exception:
|
|
393
|
-
pass
|
|
382
|
+
placeholder_names = [m.group(1) for m in re.finditer(r"\{([^}/]+)\}", path_name)]
|
|
383
|
+
existing_param_names = {p.split(":")[0].strip() for p in params.split(",") if ":" in p}
|
|
384
|
+
for ph in placeholder_names:
|
|
385
|
+
norm_ph = common.normalize_symbol(ph)
|
|
386
|
+
if norm_ph not in existing_param_names and norm_ph:
|
|
387
|
+
params = f"{norm_ph}: Any, " + params
|
|
394
388
|
|
|
395
389
|
operation_id = generate_operation_id(op, http_operation, path_name)
|
|
396
390
|
query_params = generate_query_params(op)
|
|
@@ -28,8 +28,9 @@ def create_jinja_env():
|
|
|
28
28
|
if custom_template_path is not None
|
|
29
29
|
else FileSystemLoader(TEMPLATE_PATH)
|
|
30
30
|
),
|
|
31
|
-
autoescape=
|
|
31
|
+
autoescape=False,
|
|
32
32
|
trim_blocks=True,
|
|
33
|
+
lstrip_blocks=True,
|
|
33
34
|
)
|
|
34
35
|
|
|
35
36
|
environment.filters["normalize_symbol"] = common.normalize_symbol
|
|
@@ -266,7 +266,7 @@ def _discover_discriminated_unions(
|
|
|
266
266
|
register_union(schema_name, schema)
|
|
267
267
|
|
|
268
268
|
# 2) inline/property discriminated unions
|
|
269
|
-
for
|
|
269
|
+
for _parent_name, parent_schema in components.schemas.items():
|
|
270
270
|
props = getattr(parent_schema, "properties", None) or {}
|
|
271
271
|
for prop_name, prop_schema in props.items():
|
|
272
272
|
disc = getattr(prop_schema, "discriminator", None)
|
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
from typing import Any, Dict, Optional, Union
|
|
4
4
|
|
|
5
5
|
import httpx
|
|
6
|
-
from pydantic import BaseModel
|
|
6
|
+
from pydantic import BaseModel, HttpUrl
|
|
7
7
|
|
|
8
8
|
from ..models import *
|
|
9
|
-
{% set
|
|
9
|
+
{% set _base_url = servers[0].url if servers|length > 0 else "/" %}
|
|
10
10
|
from ..exceptions import HTTPException
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
class AsyncClient(BaseModel):
|
|
14
14
|
model_config = {"validate_assignment": True}
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
base_url: str = "{{ _base_url }}"
|
|
17
17
|
verify: Union[bool, str] = True
|
|
18
18
|
{% if env_token_name is none %}
|
|
19
19
|
access_token: Optional[str] = None
|
|
@@ -41,7 +41,7 @@ class AsyncClient(BaseModel):
|
|
|
41
41
|
|
|
42
42
|
{% for op in operations %}
|
|
43
43
|
async def {{ op.operation_id }}(self{% if op.params %}, {{ op.params }}{% endif %}) -> Any:
|
|
44
|
-
|
|
44
|
+
base_url = self.base_url
|
|
45
45
|
path = f"{{ op.path_name }}"
|
|
46
46
|
|
|
47
47
|
headers = {
|
|
@@ -57,7 +57,7 @@ class AsyncClient(BaseModel):
|
|
|
57
57
|
}
|
|
58
58
|
query_params = {k: v for (k, v) in query_params.items() if v is not None}
|
|
59
59
|
|
|
60
|
-
async with httpx.AsyncClient(base_url=
|
|
60
|
+
async with httpx.AsyncClient(base_url=base_url, verify=self.verify) as client:
|
|
61
61
|
response = await client.request(
|
|
62
62
|
"{{ op.method }}",
|
|
63
63
|
httpx.URL(path),
|
ab_openapi_python_generator/language_converters/python/templates/sync_client_httpx_pydantic_2.jinja2
CHANGED
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
from typing import Any, Dict, Optional, Union
|
|
4
4
|
|
|
5
5
|
import httpx
|
|
6
|
-
from pydantic import BaseModel
|
|
6
|
+
from pydantic import BaseModel, HttpUrl
|
|
7
7
|
|
|
8
8
|
from ..models import *
|
|
9
|
-
{% set
|
|
9
|
+
{% set _base_url = servers[0].url if servers|length > 0 else "/" %}
|
|
10
10
|
from ..exceptions import HTTPException
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
class SyncClient(BaseModel):
|
|
14
14
|
model_config = {"validate_assignment": True}
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
base_url: str = "{{ _base_url }}"
|
|
17
17
|
verify: Union[bool, str] = True
|
|
18
18
|
{% if env_token_name is none %}
|
|
19
19
|
access_token: Optional[str] = None
|
|
@@ -41,7 +41,7 @@ class SyncClient(BaseModel):
|
|
|
41
41
|
|
|
42
42
|
{% for op in operations %}
|
|
43
43
|
def {{ op.operation_id }}(self{% if op.params %}, {{ op.params }}{% endif %}) -> Any:
|
|
44
|
-
|
|
44
|
+
base_url = self.base_url
|
|
45
45
|
path = f"{{ op.path_name }}"
|
|
46
46
|
|
|
47
47
|
headers = {
|
|
@@ -57,7 +57,7 @@ class SyncClient(BaseModel):
|
|
|
57
57
|
}
|
|
58
58
|
query_params = {k: v for (k, v) in query_params.items() if v is not None}
|
|
59
59
|
|
|
60
|
-
with httpx.Client(base_url=
|
|
60
|
+
with httpx.Client(base_url=base_url, verify=self.verify) as client:
|
|
61
61
|
response = client.request(
|
|
62
62
|
"{{ op.method }}",
|
|
63
63
|
httpx.URL(path),
|
|
@@ -80,21 +80,6 @@ class Model(BaseModel):
|
|
|
80
80
|
properties: List[Property] = []
|
|
81
81
|
|
|
82
82
|
|
|
83
|
-
class Service(BaseModel):
|
|
84
|
-
file_name: str
|
|
85
|
-
operations: List[ServiceOperation]
|
|
86
|
-
content: str
|
|
87
|
-
async_client: Optional[bool] = False
|
|
88
|
-
library_import: str
|
|
89
|
-
use_orjson: bool = False
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
class APIConfig(BaseModel):
|
|
93
|
-
file_name: str
|
|
94
|
-
base_url: str
|
|
95
|
-
content: str
|
|
96
|
-
|
|
97
|
-
|
|
98
83
|
class ConversionResult(BaseModel):
|
|
99
84
|
models: List[Model] = Field(default_factory=list)
|
|
100
85
|
clients: List[Model] = Field(default_factory=list)
|
{ab_openapi_python_generator-2.2.0.dist-info → ab_openapi_python_generator-2.2.2.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ab-openapi-python-generator
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.2
|
|
4
4
|
Summary: Openapi Python Generator
|
|
5
5
|
Project-URL: Homepage, https://github.com/auth-broker/openapi-python-generator
|
|
6
6
|
Project-URL: Repository, https://github.com/auth-broker/openapi-python-generator
|
{ab_openapi_python_generator-2.2.0.dist-info → ab_openapi_python_generator-2.2.2.dist-info}/RECORD
RENAMED
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
ab_openapi_python_generator/__init__.py,sha256=ph2EznAu4nkHFruaG542m4TQ_xAvDlf36uKxtAkVP1s,460
|
|
2
2
|
ab_openapi_python_generator/__main__.py,sha256=Vz0FsBvxQtyozKkZZFK_ag8XgJcx-5obRm44ogjD0Wk,2500
|
|
3
3
|
ab_openapi_python_generator/common.py,sha256=rh6AxoWyL-jb5WbeLhiohvFUBUnevn4N7ixHPKTIiDM,1221
|
|
4
|
-
ab_openapi_python_generator/generate_data.py,sha256=
|
|
5
|
-
ab_openapi_python_generator/models.py,sha256=
|
|
4
|
+
ab_openapi_python_generator/generate_data.py,sha256=s71eWNKqEv5_v0Tfb2jnIME-JOag_Jz9gKxMGT5Veq8,7944
|
|
5
|
+
ab_openapi_python_generator/models.py,sha256=pkuEbp4FrLhgoTzEZKnCVYBBvefX1oMJdbKAoMDTHfA,2031
|
|
6
6
|
ab_openapi_python_generator/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
7
|
ab_openapi_python_generator/version_detector.py,sha256=PUDTpgDMHljUzxhLhMrCzHMdS3mgYQibWDiI4-vLRB4,2104
|
|
8
8
|
ab_openapi_python_generator/language_converters/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
9
|
ab_openapi_python_generator/language_converters/python/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
|
-
ab_openapi_python_generator/language_converters/python/client_generator.py,sha256=
|
|
10
|
+
ab_openapi_python_generator/language_converters/python/client_generator.py,sha256=6TknEdUyhsBvvez0Nn_JoZuj8rmwX3k1OEnNIAzJ09A,17817
|
|
11
11
|
ab_openapi_python_generator/language_converters/python/common.py,sha256=gZHNhVC4OwGBlmr3h9Ffz3iILO1ykva9CrqhBfeYQXU,1616
|
|
12
12
|
ab_openapi_python_generator/language_converters/python/exception_generator.py,sha256=a4iX53W8qhQ99Tkdk2sHPCq3HvtZp5JctTbObgsRX7I,653
|
|
13
13
|
ab_openapi_python_generator/language_converters/python/generator.py,sha256=g-WTVLidcpDLqYW00VufmK0_jfRAM1ZVOSAcHyLAhOU,1664
|
|
14
|
-
ab_openapi_python_generator/language_converters/python/jinja_config.py,sha256=
|
|
15
|
-
ab_openapi_python_generator/language_converters/python/model_generator.py,sha256=
|
|
14
|
+
ab_openapi_python_generator/language_converters/python/jinja_config.py,sha256=EsASthmgh_XrwR7GiDooTyTiiIoqScz9HymvUpNBYFY,1210
|
|
15
|
+
ab_openapi_python_generator/language_converters/python/model_generator.py,sha256=RoHO-R-fgmBL1osmzIoPEmYAUg-9BxUSThFSbUvQYoA,34543
|
|
16
16
|
ab_openapi_python_generator/language_converters/python/templates/alias_union.jinja2,sha256=tndnrDky4srNRyB_HnUMZFW7HtoJvEfwIFteYIu0ELc,468
|
|
17
|
-
ab_openapi_python_generator/language_converters/python/templates/async_client_httpx_pydantic_2.jinja2,sha256=
|
|
17
|
+
ab_openapi_python_generator/language_converters/python/templates/async_client_httpx_pydantic_2.jinja2,sha256=U3O0BxYmbbQqmYKA1lctdd61I9f4BatF6_NgW2EOoz0,2417
|
|
18
18
|
ab_openapi_python_generator/language_converters/python/templates/discriminator_enum.jinja2,sha256=GJZ_ih1eURnJRPZq5P_3aKhYB5iJHymj2fpuNSdM90Y,163
|
|
19
19
|
ab_openapi_python_generator/language_converters/python/templates/enum.jinja2,sha256=7dewyMLifUTe9xjCTE62deuncPiNkp7eGkIaY-IWsLo,263
|
|
20
20
|
ab_openapi_python_generator/language_converters/python/templates/http_exception.jinja2,sha256=BHy48PD74aU74NGWC98iciacmGotHuWw9CaOqnCL8Kc,294
|
|
21
21
|
ab_openapi_python_generator/language_converters/python/templates/models.jinja2,sha256=s5PllbxiEENsZ5_fKSh1gKMJWhcLfBdH5744nKnAZsQ,797
|
|
22
22
|
ab_openapi_python_generator/language_converters/python/templates/models_pydantic_2.jinja2,sha256=o6-OlV5upoZOAVx6aQbsaigPMTCi4Uuec-oP1FNDJ60,904
|
|
23
|
-
ab_openapi_python_generator/language_converters/python/templates/sync_client_httpx_pydantic_2.jinja2,sha256=
|
|
23
|
+
ab_openapi_python_generator/language_converters/python/templates/sync_client_httpx_pydantic_2.jinja2,sha256=aZlljl0OD5PLrGIn4MujZkhZG6XAvoPMvLEmIDWQhdc,2393
|
|
24
24
|
ab_openapi_python_generator/parsers/__init__.py,sha256=UITDIV7rp3HAA1M8kQc_9cNG6e1tS2vDa4mTKua6aMY,300
|
|
25
25
|
ab_openapi_python_generator/parsers/openapi_30.py,sha256=2Hq5Vl3V4NUHKol-OO2nmt8-Fh6Lqk-hJUys8s-4UNI,1924
|
|
26
26
|
ab_openapi_python_generator/parsers/openapi_31.py,sha256=jyKYAKDRkqKUPSeP6xZuM6ZCE0JjuowAe_pbm01iqWE,1924
|
|
27
|
-
ab_openapi_python_generator-2.2.
|
|
28
|
-
ab_openapi_python_generator-2.2.
|
|
29
|
-
ab_openapi_python_generator-2.2.
|
|
30
|
-
ab_openapi_python_generator-2.2.
|
|
31
|
-
ab_openapi_python_generator-2.2.
|
|
27
|
+
ab_openapi_python_generator-2.2.2.dist-info/METADATA,sha256=Tx3Q2kw6jYYS9ifWRrkdWzQ1zv8F02bzPgeAmJv9Gyw,5186
|
|
28
|
+
ab_openapi_python_generator-2.2.2.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
29
|
+
ab_openapi_python_generator-2.2.2.dist-info/entry_points.txt,sha256=zezbCs2qP8lSUbcjL6cN5XHoHxf9JTe15CZYH8Yuzo0,90
|
|
30
|
+
ab_openapi_python_generator-2.2.2.dist-info/licenses/LICENSE,sha256=0myanGwJ2vUOZN12aN95o0My6XEysnnVlbKikYw3pHg,1070
|
|
31
|
+
ab_openapi_python_generator-2.2.2.dist-info/RECORD,,
|
{ab_openapi_python_generator-2.2.0.dist-info → ab_openapi_python_generator-2.2.2.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|