@typespec/http-client-python 0.37.2 → 0.38.0
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.
- package/emitter/temp/tsconfig.tsbuildinfo +1 -1
- package/eng/scripts/setup/__pycache__/package_manager.cpython-311.pyc +0 -0
- package/eng/scripts/setup/__pycache__/venvtools.cpython-311.pyc +0 -0
- package/generator/build/lib/pygen/codegen/models/response.py +5 -0
- package/generator/build/lib/pygen/codegen/serializers/builder_serializer.py +76 -23
- package/generator/build/lib/pygen/codegen/serializers/unions_serializer.py +19 -3
- package/generator/build/lib/pygen/codegen/templates/streaming_base.py.jinja2 +235 -54
- package/generator/build/lib/pygen/codegen/templates/unions.py.jinja2 +2 -2
- package/generator/build/lib/pygen/preprocess/__init__.py +33 -12
- package/generator/dist/pygen-0.1.0-py3-none-any.whl +0 -0
- package/generator/pygen/codegen/models/response.py +5 -0
- package/generator/pygen/codegen/serializers/builder_serializer.py +76 -23
- package/generator/pygen/codegen/serializers/unions_serializer.py +19 -3
- package/generator/pygen/codegen/templates/streaming_base.py.jinja2 +235 -54
- package/generator/pygen/codegen/templates/unions.py.jinja2 +2 -2
- package/generator/pygen/preprocess/__init__.py +33 -12
- package/package.json +4 -4
|
@@ -54,13 +54,14 @@ def add_overload(yaml_data: dict[str, Any], body_type: dict[str, Any], for_flatt
|
|
|
54
54
|
if yaml_data.get("initialOperation"):
|
|
55
55
|
overload["initialOperation"] = yaml_data["initialOperation"]
|
|
56
56
|
|
|
57
|
+
# Reattach shared type objects before filtering parameters so positional
|
|
58
|
+
# alignment with the original operation is preserved.
|
|
59
|
+
for overload_p, original_p in zip(overload["parameters"], yaml_data["parameters"]):
|
|
60
|
+
overload_p["type"] = original_p["type"]
|
|
57
61
|
if for_flatten_params:
|
|
58
62
|
overload["bodyParameter"]["flattened"] = True
|
|
59
63
|
else:
|
|
60
64
|
overload["parameters"] = [p for p in overload["parameters"] if not p.get("inFlattenedBody")]
|
|
61
|
-
# for yaml sync, we need to make sure all of the responses, parameters, and exceptions' types have the same yaml id
|
|
62
|
-
for overload_p, original_p in zip(overload["parameters"], yaml_data["parameters"]):
|
|
63
|
-
overload_p["type"] = original_p["type"]
|
|
64
65
|
update_overload_section(overload, yaml_data, "responses")
|
|
65
66
|
update_overload_section(overload, yaml_data, "exceptions")
|
|
66
67
|
|
|
@@ -95,12 +96,14 @@ def add_overloads_for_body_param(yaml_data: dict[str, Any], skip_single_body_jso
|
|
|
95
96
|
raw-JSON overload is kept, matching pre-TypedDict behavior).
|
|
96
97
|
"""
|
|
97
98
|
body_parameter = yaml_data["bodyParameter"]
|
|
99
|
+
body_types = body_parameter["type"].get("types", [])
|
|
98
100
|
if not (
|
|
99
101
|
body_parameter["type"]["type"] == "combined"
|
|
100
|
-
and len(
|
|
102
|
+
and len(body_types) > 1
|
|
103
|
+
and len(body_types) > len(yaml_data["overloads"])
|
|
101
104
|
):
|
|
102
105
|
return
|
|
103
|
-
for body_type in
|
|
106
|
+
for body_type in body_types:
|
|
104
107
|
if any(o for o in yaml_data["overloads"] if id(o["bodyParameter"]["type"]) == id(body_type)):
|
|
105
108
|
continue
|
|
106
109
|
if body_type.get("type") == "model" and body_type.get("base") == "json":
|
|
@@ -262,9 +265,6 @@ def _process_operation_etag_headers(
|
|
|
262
265
|
if_match_candidates: list[dict[str, Any]] = []
|
|
263
266
|
if_none_match_candidates: list[dict[str, Any]] = []
|
|
264
267
|
for p in operation["parameters"]:
|
|
265
|
-
wire_name_lower = get_wire_name_lower(p)
|
|
266
|
-
if p["location"] == "header" and wire_name_lower == "client-request-id":
|
|
267
|
-
client["requestIdHeaderName"] = wire_name_lower
|
|
268
268
|
if version_tolerant and p["location"] == "header":
|
|
269
269
|
role = _get_etag_role(p)
|
|
270
270
|
if role == "ifMatch":
|
|
@@ -273,7 +273,6 @@ def _process_operation_etag_headers(
|
|
|
273
273
|
if_none_match_candidates.append(p)
|
|
274
274
|
|
|
275
275
|
property_if_match, property_if_none_match = _resolve_etag_pair(if_match_candidates, if_none_match_candidates)
|
|
276
|
-
|
|
277
276
|
if property_if_match and property_if_none_match:
|
|
278
277
|
etag_params = {id(property_if_match), id(property_if_none_match)}
|
|
279
278
|
operation["parameters"] = [item for item in operation["parameters"] if id(item) not in etag_params] + [
|
|
@@ -284,6 +283,21 @@ def _process_operation_etag_headers(
|
|
|
284
283
|
client["hasEtag"] = True
|
|
285
284
|
|
|
286
285
|
|
|
286
|
+
def _process_operation_group_etag_headers(
|
|
287
|
+
operation_groups: list[dict[str, Any]],
|
|
288
|
+
client: dict[str, Any],
|
|
289
|
+
version_tolerant: bool,
|
|
290
|
+
) -> None:
|
|
291
|
+
for operation_group in operation_groups:
|
|
292
|
+
for operation in operation_group.get("operations", []):
|
|
293
|
+
_process_operation_etag_headers(operation, client, version_tolerant)
|
|
294
|
+
_process_operation_group_etag_headers(
|
|
295
|
+
operation_group.get("operationGroups", []),
|
|
296
|
+
client,
|
|
297
|
+
version_tolerant,
|
|
298
|
+
)
|
|
299
|
+
|
|
300
|
+
|
|
287
301
|
def headers_convert(yaml_data: dict[str, Any], replace_data: Any) -> None:
|
|
288
302
|
if isinstance(replace_data, dict):
|
|
289
303
|
for k, v in replace_data.items():
|
|
@@ -605,9 +619,16 @@ class PreProcessPlugin(YamlUpdatePlugin):
|
|
|
605
619
|
if prop_name.endswith("Client"):
|
|
606
620
|
prop_name = prop_name[: len(prop_name) - len("Client")]
|
|
607
621
|
yaml_data["builderPadName"] = to_snake_case(prop_name)
|
|
608
|
-
for
|
|
609
|
-
for
|
|
610
|
-
|
|
622
|
+
for operation_group in yaml_data.get("operationGroups", []):
|
|
623
|
+
for operation in operation_group.get("operations", []):
|
|
624
|
+
for parameter in operation["parameters"]:
|
|
625
|
+
if parameter["location"] == "header" and get_wire_name_lower(parameter) == "client-request-id":
|
|
626
|
+
yaml_data["requestIdHeaderName"] = "client-request-id"
|
|
627
|
+
_process_operation_group_etag_headers(
|
|
628
|
+
yaml_data.get("operationGroups", []),
|
|
629
|
+
yaml_data,
|
|
630
|
+
self.version_tolerant,
|
|
631
|
+
)
|
|
611
632
|
|
|
612
633
|
# add client signature cloud_setting for arm
|
|
613
634
|
if self.azure_arm and yaml_data["parameters"]:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typespec/http-client-python",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.38.0",
|
|
4
4
|
"author": "Microsoft Corporation",
|
|
5
5
|
"description": "TypeSpec emitter for Python SDKs",
|
|
6
6
|
"homepage": "https://typespec.io",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"@azure-tools/typespec-azure-core": ">=0.72.0 <1.0.0",
|
|
71
71
|
"@azure-tools/typespec-azure-resource-manager": ">=0.72.0 <1.0.0",
|
|
72
72
|
"@azure-tools/typespec-azure-rulesets": ">=0.72.0 <1.0.0",
|
|
73
|
-
"@azure-tools/typespec-client-generator-core": ">=0.72.
|
|
73
|
+
"@azure-tools/typespec-client-generator-core": ">=0.72.1 <1.0.0",
|
|
74
74
|
"@typespec/compiler": "^1.16.0",
|
|
75
75
|
"@typespec/http": "^1.16.0",
|
|
76
76
|
"@typespec/openapi": "^1.16.0",
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
"@azure-tools/typespec-azure-core": "~0.72.0",
|
|
109
109
|
"@azure-tools/typespec-azure-resource-manager": "~0.72.0",
|
|
110
110
|
"@azure-tools/typespec-azure-rulesets": "~0.72.0",
|
|
111
|
-
"@azure-tools/typespec-client-generator-core": "~0.72.
|
|
111
|
+
"@azure-tools/typespec-client-generator-core": "~0.72.1",
|
|
112
112
|
"@azure-tools/azure-http-specs": "0.1.0-alpha.45",
|
|
113
113
|
"@typespec/compiler": "^1.16.0",
|
|
114
114
|
"@typespec/http": "^1.16.0",
|
|
@@ -121,7 +121,7 @@
|
|
|
121
121
|
"@typespec/sse": "~0.86.0",
|
|
122
122
|
"@typespec/streams": "~0.86.0",
|
|
123
123
|
"@typespec/xml": "~0.86.0",
|
|
124
|
-
"@typespec/http-specs": "0.1.0-alpha.
|
|
124
|
+
"@typespec/http-specs": "0.1.0-alpha.43",
|
|
125
125
|
"@types/js-yaml": "~4.0.5",
|
|
126
126
|
"@types/node": "~25.0.2",
|
|
127
127
|
"@types/semver": "7.5.8",
|