@autorest/python 6.8.0 → 6.9.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.
@@ -43,7 +43,9 @@ class CombinedType(BaseType):
43
43
  If list: '[str]'
44
44
  If dict: '{str}'
45
45
  """
46
- raise ValueError("Shouldn't get serialization type of a combinedtype")
46
+ if not all(t for t in self.types if t.type == "constant"):
47
+ raise ValueError("Shouldn't get serialization type of a combinedtype")
48
+ return self.types[0].serialization_type
47
49
 
48
50
  @property
49
51
  def client_default_value(self) -> Any:
@@ -15,6 +15,7 @@ from .request_builder import (
15
15
  from .imports import ImportType, FileImport, TypingSection
16
16
  from .parameter_list import ParameterList
17
17
  from .model_type import ModelType
18
+ from .list_type import ListType
18
19
 
19
20
  if TYPE_CHECKING:
20
21
  from .code_model import CodeModel
@@ -63,11 +64,17 @@ class PagingOperationBase(OperationBase[PagingResponseType]):
63
64
  self.pager_async: str = yaml_data["pagerAsync"]
64
65
 
65
66
  def _get_attr_name(self, wire_name: str) -> str:
66
- response = self.responses[0]
67
+ response_type = self.responses[0].type
68
+ if not response_type:
69
+ raise ValueError(
70
+ f"Can't find a matching property in response for {wire_name}"
71
+ )
72
+ if response_type.type == "list":
73
+ response_type = cast(ListType, response_type).element_type
67
74
  try:
68
75
  return next(
69
76
  p.client_name
70
- for p in cast(ModelType, response.type).properties
77
+ for p in cast(ModelType, response_type).properties
71
78
  if p.wire_name == wire_name
72
79
  )
73
80
  except StopIteration as exc:
@@ -1126,10 +1126,7 @@ class M4Reformatter(
1126
1126
  "skipUrlEncoding": True,
1127
1127
  "inOverload": False,
1128
1128
  }
1129
- if self.version_tolerant:
1130
- parameters.append(credential)
1131
- else:
1132
- parameters.insert(0, credential)
1129
+ parameters.append(credential)
1133
1130
 
1134
1131
  def update_client(self, yaml_data: Dict[str, Any]) -> Dict[str, Any]:
1135
1132
  parameters = self.update_global_parameters(
@@ -281,7 +281,8 @@ class PreProcessPlugin(YamlUpdatePlugin): # pylint: disable=abstract-method
281
281
  yaml_data["description"], default_description=yaml_data["name"]
282
282
  )
283
283
  yaml_data["legacyFilename"] = to_snake_case(yaml_data["name"].replace(" ", "_"))
284
- for parameter in yaml_data["parameters"]:
284
+ parameters = yaml_data["parameters"]
285
+ for parameter in parameters:
285
286
  self.update_parameter(parameter)
286
287
  if parameter["clientName"] == "credential":
287
288
  policy = parameter["type"].get("policy")
@@ -294,7 +295,13 @@ class PreProcessPlugin(YamlUpdatePlugin): # pylint: disable=abstract-method
294
295
  policy["credentialScopes"] = [
295
296
  "https://management.azure.com/.default"
296
297
  ]
297
-
298
+ if (
299
+ (not self.version_tolerant or self.azure_arm)
300
+ and parameters
301
+ and parameters[-1]["clientName"] == "credential"
302
+ ):
303
+ # we need to move credential to the front in mgmt mode for backcompat reasons
304
+ yaml_data["parameters"] = [parameters[-1]] + parameters[:-1]
298
305
  prop_name = yaml_data["name"]
299
306
  if prop_name.endswith("Client"):
300
307
  prop_name = prop_name[: len(prop_name) - len("Client")]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autorest/python",
3
- "version": "6.8.0",
3
+ "version": "6.9.0",
4
4
  "description": "The Python extension for generators in AutoRest.",
5
5
  "main": "index.js",
6
6
  "repository": {