@autorest/python 6.9.5 → 6.9.7
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/autorest/codegen/__init__.py +2 -4
- package/autorest/codegen/models/base.py +2 -5
- package/autorest/codegen/models/client.py +12 -8
- package/autorest/codegen/models/code_model.py +5 -1
- package/autorest/codegen/models/combined_type.py +1 -1
- package/autorest/codegen/models/constant_type.py +1 -1
- package/autorest/codegen/models/credential_types.py +21 -11
- package/autorest/codegen/models/dictionary_type.py +1 -1
- package/autorest/codegen/models/enum_type.py +2 -2
- package/autorest/codegen/models/imports.py +18 -69
- package/autorest/codegen/models/list_type.py +1 -1
- package/autorest/codegen/models/model_type.py +1 -1
- package/autorest/codegen/models/operation.py +11 -15
- package/autorest/codegen/models/operation_group.py +2 -2
- package/autorest/codegen/models/paging_operation.py +4 -4
- package/autorest/codegen/models/parameter.py +1 -1
- package/autorest/codegen/models/primitive_types.py +12 -16
- package/autorest/codegen/models/property.py +1 -1
- package/autorest/codegen/models/request_builder.py +4 -4
- package/autorest/codegen/models/response.py +32 -10
- package/autorest/codegen/serializers/builder_serializer.py +15 -11
- package/autorest/codegen/serializers/client_serializer.py +5 -8
- package/autorest/codegen/serializers/enum_serializer.py +2 -1
- package/autorest/codegen/serializers/general_serializer.py +9 -10
- package/autorest/codegen/serializers/model_serializer.py +2 -2
- package/autorest/codegen/serializers/operation_groups_serializer.py +2 -1
- package/autorest/codegen/serializers/patch_serializer.py +2 -2
- package/autorest/codegen/serializers/request_builders_serializer.py +1 -1
- package/autorest/codegen/serializers/sample_serializer.py +17 -13
- package/autorest/codegen/serializers/types_serializer.py +1 -1
- package/autorest/codegen/templates/client.py.jinja2 +1 -1
- package/autorest/codegen/templates/enum_container.py.jinja2 +1 -1
- package/autorest/codegen/templates/model_base.py.jinja2 +12 -9
- package/autorest/codegen/templates/model_dpg.py.jinja2 +1 -1
- package/autorest/codegen/templates/model_msrest.py.jinja2 +1 -1
- package/autorest/codegen/templates/packaging_templates/LICENSE.jinja2 +1 -1
- package/autorest/codegen/templates/packaging_templates/README.md.jinja2 +1 -1
- package/autorest/codegen/templates/packaging_templates/setup.py.jinja2 +4 -4
- package/autorest/codegen/templates/patch.py.jinja2 +1 -1
- package/autorest/codegen/templates/serialization.py.jinja2 +4 -7
- package/autorest/multiapi/models/code_model.py +2 -0
- package/autorest/multiapi/serializers/__init__.py +1 -2
- package/autorest/preprocess/__init__.py +27 -25
- package/package.json +1 -1
|
@@ -24,7 +24,7 @@ with open(os.path.join(package_folder_path, "_version.py"), "r") as fd:
|
|
|
24
24
|
|
|
25
25
|
if not version:
|
|
26
26
|
raise RuntimeError("Cannot find version information")
|
|
27
|
-
{% set description = "\"" + company_name + " {} Client Library for Python\".format(PACKAGE_PPRINT_NAME)" %}
|
|
27
|
+
{% set description = "\"" + code_model.options["company_name"] + " {} Client Library for Python\".format(PACKAGE_PPRINT_NAME)" %}
|
|
28
28
|
{% set author_email = "azpysdkhelp@microsoft.com" %}
|
|
29
29
|
{% set url = "https://github.com/Azure/azure-sdk-for-python/tree/main/sdk" %}
|
|
30
30
|
{% else %}
|
|
@@ -43,10 +43,10 @@ setup(
|
|
|
43
43
|
long_description=open("README.md", "r").read(),
|
|
44
44
|
long_description_content_type="text/markdown",
|
|
45
45
|
license="MIT License",
|
|
46
|
-
author="{{ company_name }} Corporation",
|
|
46
|
+
author="{{ code_model.options["company_name"] }} Corporation",
|
|
47
47
|
{% endif %}
|
|
48
|
-
author_email="{{ author_email }}",
|
|
49
48
|
{% if not unbranded %}
|
|
49
|
+
author_email="{{ author_email }}",
|
|
50
50
|
url="{{ url }}",
|
|
51
51
|
keywords="azure, azure sdk",
|
|
52
52
|
{% endif %}
|
|
@@ -77,7 +77,7 @@ setup(
|
|
|
77
77
|
),
|
|
78
78
|
include_package_data=True,
|
|
79
79
|
package_data={
|
|
80
|
-
'
|
|
80
|
+
'{{ code_model.namespace }}': ['py.typed'],
|
|
81
81
|
},
|
|
82
82
|
{% else %}
|
|
83
83
|
packages=find_packages(),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# --------------------------------------------------------------------------
|
|
2
2
|
#
|
|
3
|
-
# Copyright (c)
|
|
3
|
+
# Copyright (c) {{ code_model.options["company_name"] }} Corporation. All rights reserved.
|
|
4
4
|
#
|
|
5
5
|
# The MIT License (MIT)
|
|
6
6
|
#
|
|
@@ -63,8 +63,8 @@ import xml.etree.ElementTree as ET
|
|
|
63
63
|
|
|
64
64
|
import isodate # type: ignore
|
|
65
65
|
|
|
66
|
-
from {{
|
|
67
|
-
from {{
|
|
66
|
+
from {{ code_model.core_library }}.exceptions import DeserializationError, SerializationError
|
|
67
|
+
from {{ code_model.core_library }}.serialization import NULL as CoreNull
|
|
68
68
|
|
|
69
69
|
_BOM = codecs.BOM_UTF8.decode(encoding="utf-8")
|
|
70
70
|
|
|
@@ -732,7 +732,6 @@ class Serializer(object):
|
|
|
732
732
|
|
|
733
733
|
if kwargs.get("skip_quote") is True:
|
|
734
734
|
output = str(output)
|
|
735
|
-
# https://github.com/Azure/autorest.python/issues/2063
|
|
736
735
|
output = output.replace("{", quote("{")).replace("}", quote("}"))
|
|
737
736
|
else:
|
|
738
737
|
output = quote(str(output), safe="")
|
|
@@ -808,7 +807,7 @@ class Serializer(object):
|
|
|
808
807
|
raise ValueError("No value for given attribute")
|
|
809
808
|
|
|
810
809
|
try:
|
|
811
|
-
if data is
|
|
810
|
+
if data is CoreNull:
|
|
812
811
|
return None
|
|
813
812
|
if data_type in self.basic_types.values():
|
|
814
813
|
return self.serialize_basic(data, data_type, **kwargs)
|
|
@@ -1217,7 +1216,6 @@ def rest_key_extractor(attr, attr_desc, data):
|
|
|
1217
1216
|
if working_data is None:
|
|
1218
1217
|
# If at any point while following flatten JSON path see None, it means
|
|
1219
1218
|
# that all properties under are None as well
|
|
1220
|
-
# https://github.com/Azure/msrest-for-python/issues/197
|
|
1221
1219
|
return None
|
|
1222
1220
|
key = ".".join(dict_keys[1:])
|
|
1223
1221
|
|
|
@@ -1238,7 +1236,6 @@ def rest_key_case_insensitive_extractor(attr, attr_desc, data):
|
|
|
1238
1236
|
if working_data is None:
|
|
1239
1237
|
# If at any point while following flatten JSON path see None, it means
|
|
1240
1238
|
# that all properties under are None as well
|
|
1241
|
-
# https://github.com/Azure/msrest-for-python/issues/197
|
|
1242
1239
|
return None
|
|
1243
1240
|
key = ".".join(dict_keys[1:])
|
|
1244
1241
|
|
|
@@ -45,6 +45,8 @@ class CodeModel: # pylint: disable=too-many-instance-attributes
|
|
|
45
45
|
default_version_metadata["global_parameters"]
|
|
46
46
|
)
|
|
47
47
|
self.user_specified_default_api = user_specified_default_api
|
|
48
|
+
self.options: Dict[str, Any] = {"unbranded": False, "company_name": "Microsoft"}
|
|
49
|
+
self.core_library = "azure.core"
|
|
48
50
|
|
|
49
51
|
@property
|
|
50
52
|
def operation_groups(self) -> List[OperationGroup]:
|
|
@@ -150,8 +150,7 @@ class MultiAPISerializer(ReaderAndWriter): # pylint: disable=abstract-method
|
|
|
150
150
|
self.write_file(
|
|
151
151
|
Path("_serialization.py"),
|
|
152
152
|
codegen_env.get_template("serialization.py.jinja2").render(
|
|
153
|
-
|
|
154
|
-
import_core_serialization="azure.core.serialization",
|
|
153
|
+
code_model=code_model,
|
|
155
154
|
),
|
|
156
155
|
)
|
|
157
156
|
|
|
@@ -20,30 +20,6 @@ from .. import YamlUpdatePlugin, YamlUpdatePluginAutorest
|
|
|
20
20
|
from .._utils import parse_args, get_body_type_for_description, JSON_REGEXP, KNOWN_TYPES
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
def add_body_param_type(
|
|
24
|
-
code_model: Dict[str, Any],
|
|
25
|
-
body_parameter: Dict[str, Any],
|
|
26
|
-
):
|
|
27
|
-
if (
|
|
28
|
-
body_parameter
|
|
29
|
-
and body_parameter["type"]["type"] in ("model", "dict", "list")
|
|
30
|
-
and any(
|
|
31
|
-
ct for ct in body_parameter.get("contentTypes", []) if JSON_REGEXP.match(ct)
|
|
32
|
-
)
|
|
33
|
-
and not body_parameter["type"].get("xmlMetadata")
|
|
34
|
-
and not any(t for t in ["flattened", "groupedBy"] if body_parameter.get(t))
|
|
35
|
-
):
|
|
36
|
-
origin_type = body_parameter["type"]["type"]
|
|
37
|
-
is_dpg_model = body_parameter["type"].get("base") == "dpg"
|
|
38
|
-
body_parameter["type"] = {
|
|
39
|
-
"type": "combined",
|
|
40
|
-
"types": [body_parameter["type"], KNOWN_TYPES["binary"]],
|
|
41
|
-
}
|
|
42
|
-
if origin_type == "model" and is_dpg_model:
|
|
43
|
-
body_parameter["type"]["types"].insert(1, KNOWN_TYPES["any-object"])
|
|
44
|
-
code_model["types"].append(body_parameter["type"])
|
|
45
|
-
|
|
46
|
-
|
|
47
23
|
def update_overload_section(
|
|
48
24
|
overload: Dict[str, Any],
|
|
49
25
|
yaml_data: Dict[str, Any],
|
|
@@ -216,6 +192,32 @@ class PreProcessPlugin(YamlUpdatePlugin): # pylint: disable=abstract-method
|
|
|
216
192
|
def is_cadl(self) -> bool:
|
|
217
193
|
return self.options.get("cadl_file", False)
|
|
218
194
|
|
|
195
|
+
def add_body_param_type(
|
|
196
|
+
self,
|
|
197
|
+
code_model: Dict[str, Any],
|
|
198
|
+
body_parameter: Dict[str, Any],
|
|
199
|
+
):
|
|
200
|
+
if (
|
|
201
|
+
body_parameter
|
|
202
|
+
and body_parameter["type"]["type"] in ("model", "dict", "list")
|
|
203
|
+
and any(
|
|
204
|
+
ct
|
|
205
|
+
for ct in body_parameter.get("contentTypes", [])
|
|
206
|
+
if JSON_REGEXP.match(ct)
|
|
207
|
+
)
|
|
208
|
+
and not body_parameter["type"].get("xmlMetadata")
|
|
209
|
+
and not any(t for t in ["flattened", "groupedBy"] if body_parameter.get(t))
|
|
210
|
+
):
|
|
211
|
+
origin_type = body_parameter["type"]["type"]
|
|
212
|
+
is_dpg_model = body_parameter["type"].get("base") == "dpg"
|
|
213
|
+
body_parameter["type"] = {
|
|
214
|
+
"type": "combined",
|
|
215
|
+
"types": [body_parameter["type"], KNOWN_TYPES["binary"]],
|
|
216
|
+
}
|
|
217
|
+
if origin_type == "model" and is_dpg_model and self.models_mode == "dpg":
|
|
218
|
+
body_parameter["type"]["types"].insert(1, KNOWN_TYPES["any-object"])
|
|
219
|
+
code_model["types"].append(body_parameter["type"])
|
|
220
|
+
|
|
219
221
|
def pad_reserved_words(self, name: str, pad_type: PadType):
|
|
220
222
|
# we want to pad hidden variables as well
|
|
221
223
|
if not name:
|
|
@@ -413,7 +415,7 @@ class PreProcessPlugin(YamlUpdatePlugin): # pylint: disable=abstract-method
|
|
|
413
415
|
response["discriminator"] = "operation"
|
|
414
416
|
if body_parameter and not is_overload:
|
|
415
417
|
# if we have a JSON body, we add a binary overload
|
|
416
|
-
add_body_param_type(code_model, body_parameter)
|
|
418
|
+
self.add_body_param_type(code_model, body_parameter)
|
|
417
419
|
add_overloads_for_body_param(yaml_data)
|
|
418
420
|
|
|
419
421
|
def _update_lro_operation_helper(self, yaml_data: Dict[str, Any]) -> None:
|