pyopenapi-gen 0.20.1__py3-none-any.whl → 0.21.1__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.
Potentially problematic release.
This version of pyopenapi-gen might be problematic. Click here for more details.
- pyopenapi_gen/__init__.py +1 -1
- pyopenapi_gen/core/utils.py +21 -2
- pyopenapi_gen/visit/endpoint/generators/url_args_generator.py +28 -4
- {pyopenapi_gen-0.20.1.dist-info → pyopenapi_gen-0.21.1.dist-info}/METADATA +1 -1
- {pyopenapi_gen-0.20.1.dist-info → pyopenapi_gen-0.21.1.dist-info}/RECORD +8 -8
- {pyopenapi_gen-0.20.1.dist-info → pyopenapi_gen-0.21.1.dist-info}/WHEEL +0 -0
- {pyopenapi_gen-0.20.1.dist-info → pyopenapi_gen-0.21.1.dist-info}/entry_points.txt +0 -0
- {pyopenapi_gen-0.20.1.dist-info → pyopenapi_gen-0.21.1.dist-info}/licenses/LICENSE +0 -0
pyopenapi_gen/__init__.py
CHANGED
|
@@ -50,7 +50,7 @@ __all__ = [
|
|
|
50
50
|
]
|
|
51
51
|
|
|
52
52
|
# Semantic version of the generator core – automatically managed by semantic-release.
|
|
53
|
-
__version__: str = "0.
|
|
53
|
+
__version__: str = "0.21.1"
|
|
54
54
|
|
|
55
55
|
# ---------------------------------------------------------------------------
|
|
56
56
|
# Lazy-loading and autocompletion support (This part remains)
|
pyopenapi_gen/core/utils.py
CHANGED
|
@@ -328,10 +328,12 @@ class DataclassSerializer:
|
|
|
328
328
|
The serialized object with dataclasses converted to dictionaries.
|
|
329
329
|
|
|
330
330
|
Handles:
|
|
331
|
-
-
|
|
331
|
+
- BaseSchema instances: Uses to_dict() method with field name mapping (e.g., snake_case -> camelCase)
|
|
332
|
+
- Regular dataclass instances: Converted to dictionaries using field names
|
|
332
333
|
- Lists: Recursively serialize each item
|
|
333
334
|
- Dictionaries: Recursively serialize values
|
|
334
335
|
- datetime: Convert to ISO format string
|
|
336
|
+
- Enums: Convert to their value
|
|
335
337
|
- Primitives: Return unchanged
|
|
336
338
|
- None values: Excluded from output
|
|
337
339
|
"""
|
|
@@ -363,7 +365,24 @@ class DataclassSerializer:
|
|
|
363
365
|
if isinstance(obj, Enum) and not isinstance(obj, type):
|
|
364
366
|
return obj.value
|
|
365
367
|
|
|
366
|
-
# Handle
|
|
368
|
+
# Handle BaseSchema instances (respects field name mappings)
|
|
369
|
+
# Check for BaseSchema by looking for both to_dict and _get_field_mappings methods
|
|
370
|
+
if hasattr(obj, "to_dict") and hasattr(obj, "_get_field_mappings") and callable(obj.to_dict):
|
|
371
|
+
visited.add(obj_id)
|
|
372
|
+
try:
|
|
373
|
+
# Use BaseSchema's to_dict() which handles field name mapping
|
|
374
|
+
result_dict = obj.to_dict(exclude_none=True)
|
|
375
|
+
# Recursively serialize nested objects in the result
|
|
376
|
+
serialized_result = {}
|
|
377
|
+
for key, value in result_dict.items():
|
|
378
|
+
serialized_value = DataclassSerializer._serialize_with_tracking(value, visited)
|
|
379
|
+
if serialized_value is not None:
|
|
380
|
+
serialized_result[key] = serialized_value
|
|
381
|
+
return serialized_result
|
|
382
|
+
finally:
|
|
383
|
+
visited.discard(obj_id)
|
|
384
|
+
|
|
385
|
+
# Handle regular dataclass instances (no field mapping)
|
|
367
386
|
if dataclasses.is_dataclass(obj) and not isinstance(obj, type):
|
|
368
387
|
visited.add(obj_id)
|
|
369
388
|
try:
|
|
@@ -43,17 +43,22 @@ class EndpointUrlArgsGenerator:
|
|
|
43
43
|
# writer.write_line("# No query parameters to write") # Optional: for clarity during debugging
|
|
44
44
|
return
|
|
45
45
|
|
|
46
|
+
# Import DataclassSerializer since we use it for parameter serialization
|
|
47
|
+
context.add_import(f"{context.core_package_name}.utils", "DataclassSerializer")
|
|
48
|
+
|
|
46
49
|
for i, p in enumerate(query_params_to_write):
|
|
47
50
|
param_var_name = NameSanitizer.sanitize_method_name(p["name"]) # Ensure name is sanitized
|
|
48
51
|
original_param_name = p["original_name"]
|
|
49
52
|
line_end = "," # Always add comma, let formatter handle final one if needed
|
|
50
53
|
|
|
51
54
|
if p.get("required", False):
|
|
52
|
-
writer.write_line(
|
|
55
|
+
writer.write_line(
|
|
56
|
+
f' "{original_param_name}": DataclassSerializer.serialize({param_var_name}){line_end}'
|
|
57
|
+
)
|
|
53
58
|
else:
|
|
54
59
|
# Using dict unpacking for conditional parameters
|
|
55
60
|
writer.write_line(
|
|
56
|
-
f' **({{"{original_param_name}": {param_var_name}}} '
|
|
61
|
+
f' **({{"{original_param_name}": DataclassSerializer.serialize({param_var_name})}} '
|
|
57
62
|
f"if {param_var_name} is not None else {{}}){line_end}"
|
|
58
63
|
)
|
|
59
64
|
|
|
@@ -66,6 +71,10 @@ class EndpointUrlArgsGenerator:
|
|
|
66
71
|
# if ordered_params is the sole source of truth for method params.
|
|
67
72
|
header_params_to_write = [p for p in ordered_params if p.get("param_in") == "header"]
|
|
68
73
|
|
|
74
|
+
# Import DataclassSerializer since we use it for parameter serialization
|
|
75
|
+
if header_params_to_write:
|
|
76
|
+
context.add_import(f"{context.core_package_name}.utils", "DataclassSerializer")
|
|
77
|
+
|
|
69
78
|
for p_info in header_params_to_write:
|
|
70
79
|
param_var_name = NameSanitizer.sanitize_method_name(
|
|
71
80
|
p_info["name"]
|
|
@@ -74,13 +83,15 @@ class EndpointUrlArgsGenerator:
|
|
|
74
83
|
line_end = ","
|
|
75
84
|
|
|
76
85
|
if p_info.get("required", False):
|
|
77
|
-
writer.write_line(
|
|
86
|
+
writer.write_line(
|
|
87
|
+
f' "{original_header_name}": DataclassSerializer.serialize({param_var_name}){line_end}'
|
|
88
|
+
)
|
|
78
89
|
else:
|
|
79
90
|
# Conditional inclusion for optional headers
|
|
80
91
|
# This assumes that if an optional header parameter is None, it should not be sent.
|
|
81
92
|
# If specific behavior (e.g. empty string) is needed for None, logic would adjust.
|
|
82
93
|
writer.write_line(
|
|
83
|
-
f' **({{"{original_header_name}": {param_var_name}}} '
|
|
94
|
+
f' **({{"{original_header_name}": DataclassSerializer.serialize({param_var_name})}} '
|
|
84
95
|
f"if {param_var_name} is not None else {{}}){line_end}"
|
|
85
96
|
)
|
|
86
97
|
|
|
@@ -95,6 +106,19 @@ class EndpointUrlArgsGenerator:
|
|
|
95
106
|
) -> bool:
|
|
96
107
|
"""Writes URL, query, and header parameters. Returns True if header params were written."""
|
|
97
108
|
# Main logic from EndpointMethodGenerator._write_url_and_args
|
|
109
|
+
|
|
110
|
+
# Serialize path parameters before URL construction
|
|
111
|
+
# This ensures enums, dates, and other complex types are converted to strings
|
|
112
|
+
# before f-string interpolation in the URL
|
|
113
|
+
path_params = [p for p in ordered_params if p.get("param_in") == "path"]
|
|
114
|
+
if path_params:
|
|
115
|
+
# Import DataclassSerializer since we use it for parameter serialization
|
|
116
|
+
context.add_import(f"{context.core_package_name}.utils", "DataclassSerializer")
|
|
117
|
+
for p in path_params:
|
|
118
|
+
param_var_name = NameSanitizer.sanitize_method_name(p["name"])
|
|
119
|
+
writer.write_line(f"{param_var_name} = DataclassSerializer.serialize({param_var_name})")
|
|
120
|
+
writer.write_line("") # Blank line after path param serialization
|
|
121
|
+
|
|
98
122
|
url_expr = self._build_url_with_path_vars(op.path)
|
|
99
123
|
writer.write_line(f"url = {url_expr}")
|
|
100
124
|
writer.write_line("") # Add a blank line for readability
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyopenapi-gen
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.21.1
|
|
4
4
|
Summary: Modern, async-first Python client generator for OpenAPI specifications with advanced cycle detection and unified type resolution
|
|
5
5
|
Project-URL: Homepage, https://github.com/your-org/pyopenapi-gen
|
|
6
6
|
Project-URL: Documentation, https://github.com/your-org/pyopenapi-gen/blob/main/README.md
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
pyopenapi_gen/__init__.py,sha256=
|
|
1
|
+
pyopenapi_gen/__init__.py,sha256=uPKVj6G1lbzsS8QC9dCe8MBuRL6XKf4r5aw156jlqkU,7533
|
|
2
2
|
pyopenapi_gen/__main__.py,sha256=4-SCaCNhBd7rtyRK58uoDbdl93J0KhUeajP_b0CPpLE,110
|
|
3
3
|
pyopenapi_gen/cli.py,sha256=9T_XF3-ih_JlM_BOkmHft-HoMCGOqL5UrnAHBJ0fb5w,2320
|
|
4
4
|
pyopenapi_gen/http_types.py,sha256=EMMYZBt8PNVZKPFu77TQija-JI-nOKyXvpiQP9-VSWE,467
|
|
@@ -18,7 +18,7 @@ pyopenapi_gen/core/postprocess_manager.py,sha256=Ia4H47lInhVxkHnDB46t4U-6BLpLXzh
|
|
|
18
18
|
pyopenapi_gen/core/schemas.py,sha256=Ngehd-Aj4Drs_5i7eL0L5Eu1B_kfT4qxL94TJ_H_I7w,5523
|
|
19
19
|
pyopenapi_gen/core/streaming_helpers.py,sha256=5fkzH9xsgzZWOTKFrZpmje07S7n7CcOpjteb5dig7ds,2664
|
|
20
20
|
pyopenapi_gen/core/telemetry.py,sha256=LNMrlrUNVcp591w9cX4uvzlFrPB6ZZoGRIuCOHlDCqA,2296
|
|
21
|
-
pyopenapi_gen/core/utils.py,sha256
|
|
21
|
+
pyopenapi_gen/core/utils.py,sha256=VK2TojBe6esfbhSy87kpra4Cguc0iv5teD-T7beI43Q,15435
|
|
22
22
|
pyopenapi_gen/core/warning_collector.py,sha256=DYl9D7eZYs04mDU84KeonS-5-d0aM7hNqraXTex31ss,2799
|
|
23
23
|
pyopenapi_gen/core/auth/base.py,sha256=E2KUerA_mYv9D7xulUm-lenIxqZHqanjA4oRKpof2ZE,792
|
|
24
24
|
pyopenapi_gen/core/auth/plugins.py,sha256=u4GZTykoxGwGaWAQyFeTdPKi-pSK7Dp0DCeg5RsrSw4,3446
|
|
@@ -117,7 +117,7 @@ pyopenapi_gen/visit/endpoint/generators/overload_generator.py,sha256=XijowsP3SS6
|
|
|
117
117
|
pyopenapi_gen/visit/endpoint/generators/request_generator.py,sha256=MKtZ6Fa050gCgqAGhXeo--p_AzqV9RmDd8e4Zvglgo0,5349
|
|
118
118
|
pyopenapi_gen/visit/endpoint/generators/response_handler_generator.py,sha256=Jb_8hRQY1OfpThupa7UdCNxa712m3WaeNIbLhlYk1bg,24193
|
|
119
119
|
pyopenapi_gen/visit/endpoint/generators/signature_generator.py,sha256=ENi34Rf2x1Ijtvca652ihV9L2UUT1O2SEsG-66Pm_Z8,3873
|
|
120
|
-
pyopenapi_gen/visit/endpoint/generators/url_args_generator.py,sha256=
|
|
120
|
+
pyopenapi_gen/visit/endpoint/generators/url_args_generator.py,sha256=DWKtgjj9JzaSd6i-7RoAzHo5uMLZ0GjCHpvHG50CbgY,10922
|
|
121
121
|
pyopenapi_gen/visit/endpoint/processors/__init__.py,sha256=_6RqpOdDuDheArqDBi3ykhsaetACny88WUuuAJvr_ME,29
|
|
122
122
|
pyopenapi_gen/visit/endpoint/processors/import_analyzer.py,sha256=ou5pl3S6PXvHrhKeBQraRfK9MTOQE1WUGLeieAVUXRM,3364
|
|
123
123
|
pyopenapi_gen/visit/endpoint/processors/parameter_processor.py,sha256=E0VoygkhU8iCsvH0U-tA6ZZg2Nm3rfr4e17vxqQLH7c,7666
|
|
@@ -126,8 +126,8 @@ pyopenapi_gen/visit/model/alias_generator.py,sha256=wEMHipPA1_CFxvQ6CS9j4qgXK93s
|
|
|
126
126
|
pyopenapi_gen/visit/model/dataclass_generator.py,sha256=L794s2yyYUO__akGd120NJMV7g2xqiPfQyZo8CduIVM,14426
|
|
127
127
|
pyopenapi_gen/visit/model/enum_generator.py,sha256=AXqKUFuWUUjUF_6_HqBKY8vB5GYu35Pb2C2WPFrOw1k,10061
|
|
128
128
|
pyopenapi_gen/visit/model/model_visitor.py,sha256=TC6pbxpQiy5FWhmQpfllLuXA3ImTYNMcrazkOFZCIyo,9470
|
|
129
|
-
pyopenapi_gen-0.
|
|
130
|
-
pyopenapi_gen-0.
|
|
131
|
-
pyopenapi_gen-0.
|
|
132
|
-
pyopenapi_gen-0.
|
|
133
|
-
pyopenapi_gen-0.
|
|
129
|
+
pyopenapi_gen-0.21.1.dist-info/METADATA,sha256=K25EjI3531dEiR-boznZr51FI7mJEJb3T01hQSTl-8Y,20551
|
|
130
|
+
pyopenapi_gen-0.21.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
131
|
+
pyopenapi_gen-0.21.1.dist-info/entry_points.txt,sha256=gxSlNiwom50T3OEZnlocA6qRjGdV0bn6hN_Xr-Ub5wA,56
|
|
132
|
+
pyopenapi_gen-0.21.1.dist-info/licenses/LICENSE,sha256=UFAyTWKa4w10-QerlJaHJeep7G2gcwpf-JmvI2dS2Gc,1088
|
|
133
|
+
pyopenapi_gen-0.21.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|