@autorest/python 6.40.0 → 6.41.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/generator/build/lib/pygen/codegen/models/paging_operation.py +4 -0
- package/generator/build/lib/pygen/codegen/models/parameter.py +1 -1
- package/generator/build/lib/pygen/codegen/serializers/builder_serializer.py +7 -0
- package/generator/build/lib/pygen/codegen/templates/serialization.py.jinja2 +1 -1
- package/generator/build/lib/pygen/preprocess/__init__.py +13 -3
- package/generator/dist/pygen-0.1.0-py3-none-any.whl +0 -0
- package/generator/pygen/codegen/models/paging_operation.py +4 -0
- package/generator/pygen/codegen/models/parameter.py +1 -1
- package/generator/pygen/codegen/serializers/builder_serializer.py +7 -0
- package/generator/pygen/codegen/templates/serialization.py.jinja2 +1 -1
- package/generator/pygen/preprocess/__init__.py +13 -3
- package/package.json +2 -2
- package/scripts/__pycache__/venvtools.cpython-310.pyc +0 -0
|
@@ -96,6 +96,10 @@ class PagingOperationBase(OperationBase[PagingResponseType]):
|
|
|
96
96
|
return self._get_attr_name(wire_name)
|
|
97
97
|
return wire_name
|
|
98
98
|
|
|
99
|
+
@property
|
|
100
|
+
def next_link_is_nested(self) -> bool:
|
|
101
|
+
return self.yaml_data.get("nextLinkIsNested", False)
|
|
102
|
+
|
|
99
103
|
@property
|
|
100
104
|
def item_name(self) -> str:
|
|
101
105
|
wire_name = self.yaml_data["itemName"]
|
|
@@ -63,7 +63,7 @@ class _ParameterBase(BaseModel, abc.ABC): # pylint: disable=too-many-instance-a
|
|
|
63
63
|
self.wire_name: str = yaml_data.get("wireName", "")
|
|
64
64
|
self.client_name: str = self.yaml_data["clientName"]
|
|
65
65
|
self.optional: bool = self.yaml_data["optional"]
|
|
66
|
-
self.implementation: str = yaml_data.get("implementation", None)
|
|
66
|
+
self.implementation: Optional[str] = yaml_data.get("implementation", None)
|
|
67
67
|
self.location: ParameterLocation = self.yaml_data["location"]
|
|
68
68
|
self.client_default_value = self.yaml_data.get("clientDefaultValue", None)
|
|
69
69
|
self.in_docstring = self.yaml_data.get("inDocstring", True)
|
|
@@ -1383,6 +1383,13 @@ class _PagingOperationSerializer(_OperationSerializer[PagingOperationType]):
|
|
|
1383
1383
|
cont_token_property = "None"
|
|
1384
1384
|
elif self.code_model.options["models-mode"] == "msrest":
|
|
1385
1385
|
cont_token_property = f"deserialized.{next_link_name} or None"
|
|
1386
|
+
elif builder.next_link_is_nested:
|
|
1387
|
+
next_link_name_array = next_link_name.split(".")
|
|
1388
|
+
access = (
|
|
1389
|
+
"".join([f'.get("{i}", {{}})' for i in next_link_name_array[:-1]])
|
|
1390
|
+
+ f'.get("{next_link_name_array[-1]}")'
|
|
1391
|
+
)
|
|
1392
|
+
cont_token_property = f"deserialized{access} or None"
|
|
1386
1393
|
else:
|
|
1387
1394
|
cont_token_property = f'deserialized.get("{next_link_name}") or None'
|
|
1388
1395
|
list_type = "AsyncList" if self.async_mode else "iter"
|
|
@@ -783,7 +783,7 @@ class Serializer: # pylint: disable=too-many-public-methods
|
|
|
783
783
|
|
|
784
784
|
# If dependencies is empty, try with current data class
|
|
785
785
|
# It has to be a subclass of Enum anyway
|
|
786
|
-
enum_type = self.dependencies.get(data_type, data.__class__)
|
|
786
|
+
enum_type = self.dependencies.get(data_type, cast(type, data.__class__))
|
|
787
787
|
if issubclass(enum_type, Enum):
|
|
788
788
|
return Serializer.serialize_enum(data, enum_obj=enum_type)
|
|
789
789
|
|
|
@@ -213,7 +213,10 @@ class PreProcessPlugin(YamlUpdatePlugin):
|
|
|
213
213
|
and not any(t for t in ["flattened", "groupedBy"] if body_parameter.get(t))
|
|
214
214
|
):
|
|
215
215
|
origin_type = body_parameter["type"]["type"]
|
|
216
|
-
|
|
216
|
+
model_type = (
|
|
217
|
+
body_parameter["type"] if origin_type == "model" else body_parameter["type"].get("elementType", {})
|
|
218
|
+
)
|
|
219
|
+
is_dpg_model = model_type.get("base") == "dpg"
|
|
217
220
|
body_parameter["type"] = {
|
|
218
221
|
"type": "combined",
|
|
219
222
|
"types": [body_parameter["type"]],
|
|
@@ -222,8 +225,15 @@ class PreProcessPlugin(YamlUpdatePlugin):
|
|
|
222
225
|
if not (self.is_tsp and has_multi_part_content_type(body_parameter)):
|
|
223
226
|
body_parameter["type"]["types"].append(KNOWN_TYPES["binary"])
|
|
224
227
|
|
|
225
|
-
if
|
|
226
|
-
|
|
228
|
+
if self.options["models-mode"] == "dpg" and is_dpg_model:
|
|
229
|
+
if origin_type == "model":
|
|
230
|
+
body_parameter["type"]["types"].insert(1, KNOWN_TYPES["any-object"])
|
|
231
|
+
else:
|
|
232
|
+
# dict or list
|
|
233
|
+
# copy the original dict / list type
|
|
234
|
+
any_obj_list_or_dict = copy.deepcopy(body_parameter["type"]["types"][0])
|
|
235
|
+
any_obj_list_or_dict["elementType"] = KNOWN_TYPES["any-object"]
|
|
236
|
+
body_parameter["type"]["types"].insert(1, any_obj_list_or_dict)
|
|
227
237
|
code_model["types"].append(body_parameter["type"])
|
|
228
238
|
|
|
229
239
|
def pad_reserved_words(self, name: str, pad_type: PadType):
|
|
Binary file
|
|
@@ -96,6 +96,10 @@ class PagingOperationBase(OperationBase[PagingResponseType]):
|
|
|
96
96
|
return self._get_attr_name(wire_name)
|
|
97
97
|
return wire_name
|
|
98
98
|
|
|
99
|
+
@property
|
|
100
|
+
def next_link_is_nested(self) -> bool:
|
|
101
|
+
return self.yaml_data.get("nextLinkIsNested", False)
|
|
102
|
+
|
|
99
103
|
@property
|
|
100
104
|
def item_name(self) -> str:
|
|
101
105
|
wire_name = self.yaml_data["itemName"]
|
|
@@ -63,7 +63,7 @@ class _ParameterBase(BaseModel, abc.ABC): # pylint: disable=too-many-instance-a
|
|
|
63
63
|
self.wire_name: str = yaml_data.get("wireName", "")
|
|
64
64
|
self.client_name: str = self.yaml_data["clientName"]
|
|
65
65
|
self.optional: bool = self.yaml_data["optional"]
|
|
66
|
-
self.implementation: str = yaml_data.get("implementation", None)
|
|
66
|
+
self.implementation: Optional[str] = yaml_data.get("implementation", None)
|
|
67
67
|
self.location: ParameterLocation = self.yaml_data["location"]
|
|
68
68
|
self.client_default_value = self.yaml_data.get("clientDefaultValue", None)
|
|
69
69
|
self.in_docstring = self.yaml_data.get("inDocstring", True)
|
|
@@ -1383,6 +1383,13 @@ class _PagingOperationSerializer(_OperationSerializer[PagingOperationType]):
|
|
|
1383
1383
|
cont_token_property = "None"
|
|
1384
1384
|
elif self.code_model.options["models-mode"] == "msrest":
|
|
1385
1385
|
cont_token_property = f"deserialized.{next_link_name} or None"
|
|
1386
|
+
elif builder.next_link_is_nested:
|
|
1387
|
+
next_link_name_array = next_link_name.split(".")
|
|
1388
|
+
access = (
|
|
1389
|
+
"".join([f'.get("{i}", {{}})' for i in next_link_name_array[:-1]])
|
|
1390
|
+
+ f'.get("{next_link_name_array[-1]}")'
|
|
1391
|
+
)
|
|
1392
|
+
cont_token_property = f"deserialized{access} or None"
|
|
1386
1393
|
else:
|
|
1387
1394
|
cont_token_property = f'deserialized.get("{next_link_name}") or None'
|
|
1388
1395
|
list_type = "AsyncList" if self.async_mode else "iter"
|
|
@@ -783,7 +783,7 @@ class Serializer: # pylint: disable=too-many-public-methods
|
|
|
783
783
|
|
|
784
784
|
# If dependencies is empty, try with current data class
|
|
785
785
|
# It has to be a subclass of Enum anyway
|
|
786
|
-
enum_type = self.dependencies.get(data_type, data.__class__)
|
|
786
|
+
enum_type = self.dependencies.get(data_type, cast(type, data.__class__))
|
|
787
787
|
if issubclass(enum_type, Enum):
|
|
788
788
|
return Serializer.serialize_enum(data, enum_obj=enum_type)
|
|
789
789
|
|
|
@@ -213,7 +213,10 @@ class PreProcessPlugin(YamlUpdatePlugin):
|
|
|
213
213
|
and not any(t for t in ["flattened", "groupedBy"] if body_parameter.get(t))
|
|
214
214
|
):
|
|
215
215
|
origin_type = body_parameter["type"]["type"]
|
|
216
|
-
|
|
216
|
+
model_type = (
|
|
217
|
+
body_parameter["type"] if origin_type == "model" else body_parameter["type"].get("elementType", {})
|
|
218
|
+
)
|
|
219
|
+
is_dpg_model = model_type.get("base") == "dpg"
|
|
217
220
|
body_parameter["type"] = {
|
|
218
221
|
"type": "combined",
|
|
219
222
|
"types": [body_parameter["type"]],
|
|
@@ -222,8 +225,15 @@ class PreProcessPlugin(YamlUpdatePlugin):
|
|
|
222
225
|
if not (self.is_tsp and has_multi_part_content_type(body_parameter)):
|
|
223
226
|
body_parameter["type"]["types"].append(KNOWN_TYPES["binary"])
|
|
224
227
|
|
|
225
|
-
if
|
|
226
|
-
|
|
228
|
+
if self.options["models-mode"] == "dpg" and is_dpg_model:
|
|
229
|
+
if origin_type == "model":
|
|
230
|
+
body_parameter["type"]["types"].insert(1, KNOWN_TYPES["any-object"])
|
|
231
|
+
else:
|
|
232
|
+
# dict or list
|
|
233
|
+
# copy the original dict / list type
|
|
234
|
+
any_obj_list_or_dict = copy.deepcopy(body_parameter["type"]["types"][0])
|
|
235
|
+
any_obj_list_or_dict["elementType"] = KNOWN_TYPES["any-object"]
|
|
236
|
+
body_parameter["type"]["types"].insert(1, any_obj_list_or_dict)
|
|
227
237
|
code_model["types"].append(body_parameter["type"])
|
|
228
238
|
|
|
229
239
|
def pad_reserved_words(self, name: str, pad_type: PadType):
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autorest/python",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.41.0",
|
|
4
4
|
"description": "The Python extension for generators in AutoRest.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"homepage": "https://github.com/Azure/autorest.python/blob/main/README.md",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@typespec/http-client-python": "~0.
|
|
22
|
+
"@typespec/http-client-python": "~0.18.0",
|
|
23
23
|
"@autorest/system-requirements": "~1.0.2",
|
|
24
24
|
"fs-extra": "~11.2.0",
|
|
25
25
|
"tsx": "~4.19.1"
|
|
Binary file
|