@autorest/python 6.2.3 → 6.2.4
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.
|
@@ -172,10 +172,7 @@ class Client(_ClientConfigBase[ClientGlobalParameterList]):
|
|
|
172
172
|
)
|
|
173
173
|
|
|
174
174
|
for gp in self.parameters:
|
|
175
|
-
if
|
|
176
|
-
gp.method_location == ParameterMethodLocation.KWARG
|
|
177
|
-
and gp not in self.parameters.kwargs_to_pop
|
|
178
|
-
):
|
|
175
|
+
if gp.method_location == ParameterMethodLocation.KWARG:
|
|
179
176
|
continue
|
|
180
177
|
file_import.merge(gp.imports(async_mode))
|
|
181
178
|
file_import.add_submodule_import(
|
|
@@ -393,6 +393,15 @@ class _RequestBuilderParameterList(
|
|
|
393
393
|
p for p in super().path if p.location != ParameterLocation.ENDPOINT_PATH
|
|
394
394
|
]
|
|
395
395
|
|
|
396
|
+
@property
|
|
397
|
+
def constant(
|
|
398
|
+
self,
|
|
399
|
+
) -> List[Union[RequestBuilderParameter, RequestBuilderBodyParameterType]]:
|
|
400
|
+
"""All constant parameters"""
|
|
401
|
+
return [
|
|
402
|
+
p for p in super().constant if p.location != ParameterLocation.ENDPOINT_PATH
|
|
403
|
+
]
|
|
404
|
+
|
|
396
405
|
|
|
397
406
|
class RequestBuilderParameterList(_RequestBuilderParameterList):
|
|
398
407
|
"""Parameter list for Request Builder"""
|
|
@@ -463,15 +472,6 @@ class ClientGlobalParameterList(_ClientGlobalParameterList[ClientParameter]):
|
|
|
463
472
|
except StopIteration:
|
|
464
473
|
return None
|
|
465
474
|
|
|
466
|
-
@property
|
|
467
|
-
def kwargs_to_pop(self) -> List[Union[ClientParameter, BodyParameter]]:
|
|
468
|
-
"""We only want to pass base url path parameters in the client"""
|
|
469
|
-
return [
|
|
470
|
-
k
|
|
471
|
-
for k in super().kwargs_to_pop
|
|
472
|
-
if k.location == ParameterLocation.ENDPOINT_PATH
|
|
473
|
-
]
|
|
474
|
-
|
|
475
475
|
|
|
476
476
|
class ConfigGlobalParameterList(_ClientGlobalParameterList[ConfigParameter]):
|
|
477
477
|
"""Parameter list for config"""
|
|
@@ -87,6 +87,15 @@ class SampleSerializer:
|
|
|
87
87
|
|
|
88
88
|
return client_params
|
|
89
89
|
|
|
90
|
+
@staticmethod
|
|
91
|
+
def handle_param(param: Any) -> str:
|
|
92
|
+
if isinstance(param, str):
|
|
93
|
+
if any(i in param for i in '\r\n"'):
|
|
94
|
+
return f'"""{param}"""'
|
|
95
|
+
return f'"{param}"'
|
|
96
|
+
|
|
97
|
+
return str(param)
|
|
98
|
+
|
|
90
99
|
# prepare operation parameters
|
|
91
100
|
def _operation_params(self) -> Dict[str, Any]:
|
|
92
101
|
params_positional = [
|
|
@@ -94,7 +103,6 @@ class SampleSerializer:
|
|
|
94
103
|
for p in self.operation.parameters.positional
|
|
95
104
|
if not p.client_default_value
|
|
96
105
|
]
|
|
97
|
-
cls = lambda x: f'"{x}"' if isinstance(x, str) else str(x)
|
|
98
106
|
failure_info = "fail to find required param named {} in example file {}"
|
|
99
107
|
operation_params = {}
|
|
100
108
|
for param in params_positional:
|
|
@@ -103,7 +111,7 @@ class SampleSerializer:
|
|
|
103
111
|
if not param.optional:
|
|
104
112
|
if not param_value:
|
|
105
113
|
raise Exception(failure_info.format(name, self.sample_origin_name))
|
|
106
|
-
operation_params[param.client_name] =
|
|
114
|
+
operation_params[param.client_name] = self.handle_param(param_value)
|
|
107
115
|
return operation_params
|
|
108
116
|
|
|
109
117
|
def _operation_group_name(self) -> str:
|
|
@@ -5,9 +5,6 @@
|
|
|
5
5
|
{{ serializer.init_signature_and_response_type_annotation(async_mode) | indent }}
|
|
6
6
|
{% if serializer.should_init_super %}
|
|
7
7
|
super().__init__()
|
|
8
|
-
{% endif %}
|
|
9
|
-
{% if client.parameters.kwargs_to_pop %}
|
|
10
|
-
{{ op_tools.serialize(serializer.pop_kwargs_from_signature()) | indent(8) }}
|
|
11
8
|
{% endif %}
|
|
12
9
|
{% if client.has_parameterized_host %}
|
|
13
10
|
{{ serializer.host_variable_name }} = {{ keywords.escape_str(client.url) }}
|