@typespec/http-client-python 0.27.2 → 0.28.1
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/dist/emitter/code-model.d.ts.map +1 -1
- package/dist/emitter/code-model.js +2 -1
- package/dist/emitter/code-model.js.map +1 -1
- package/dist/emitter/emitter.js +1 -1
- package/dist/emitter/emitter.js.map +1 -1
- package/dist/emitter/http.d.ts.map +1 -1
- package/dist/emitter/http.js +2 -13
- package/dist/emitter/http.js.map +1 -1
- package/emitter/src/code-model.ts +2 -1
- package/emitter/src/emitter.ts +1 -1
- package/emitter/src/http.ts +1 -13
- package/emitter/temp/tsconfig.tsbuildinfo +1 -1
- package/eng/scripts/Build-Packages.ps1 +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/eng/scripts/setup/package_manager.py +2 -2
- package/generator/build/lib/pygen/codegen/models/parameter.py +10 -4
- package/generator/build/lib/pygen/codegen/templates/model_base.py.jinja2 +6 -2
- package/generator/build/lib/pygen/preprocess/__init__.py +9 -21
- package/generator/build/lib/pygen/preprocess/python_mappings.py +0 -2
- package/generator/component-detection-pip-report.json +5 -6
- package/generator/dist/pygen-0.1.0-py3-none-any.whl +0 -0
- package/generator/pygen/codegen/models/parameter.py +10 -4
- package/generator/pygen/codegen/templates/model_base.py.jinja2 +6 -2
- package/generator/pygen/preprocess/__init__.py +9 -21
- package/generator/pygen/preprocess/python_mappings.py +0 -2
- package/generator/test/azure/mock_api_tests/asynctests/test_azure_client_generator_core_flatten_async.py +24 -2
- package/generator/test/azure/mock_api_tests/asynctests/test_client_naming_async.py +5 -5
- package/generator/test/azure/mock_api_tests/asynctests/test_client_structure_async.py +13 -11
- package/generator/test/azure/mock_api_tests/asynctests/test_client_structure_clientoperationgroup_async.py +6 -4
- package/generator/test/azure/mock_api_tests/asynctests/test_special_words_async.py +6 -0
- package/generator/test/azure/mock_api_tests/test_azure_client_generator_core_flatten.py +22 -2
- package/generator/test/azure/mock_api_tests/test_client_naming.py +5 -5
- package/generator/test/azure/mock_api_tests/test_client_structure.py +12 -9
- package/generator/test/azure/mock_api_tests/test_client_structure_clientoperationgroup.py +7 -4
- package/generator/test/azure/mock_api_tests/test_special_words.py +5 -0
- package/generator/test/azure/requirements.txt +0 -1
- package/generator/test/generic_mock_api_tests/asynctests/test_authentication_async.py +13 -1
- package/generator/test/generic_mock_api_tests/asynctests/test_payload_pageable_async.py +7 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_payload_xml_async.py +1 -0
- package/generator/test/generic_mock_api_tests/test_authentication.py +11 -1
- package/generator/test/generic_mock_api_tests/test_payload_pageable.py +6 -0
- package/generator/test/generic_mock_api_tests/test_payload_xml.py +1 -0
- package/generator/test/unbranded/mock_api_tests/asynctests/test_special_words_async.py +7 -0
- package/generator/test/unbranded/mock_api_tests/test_special_words.py +6 -0
- package/generator/test/unittests/test_enums.py +37 -0
- package/generator/test/unittests/test_model_base_xml_serialization.py +244 -2
- package/generator/test/unittests/test_name_converter.py +0 -8
- package/package.json +33 -33
- package/generator/test/azure/mock_api_tests/asynctests/test_azure_resource_manager_multi_service_older_versions_async.py +0 -111
- package/generator/test/azure/mock_api_tests/test_azure_resource_manager_multi_service_older_versions.py +0 -107
|
@@ -77,7 +77,7 @@ finally {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
if ($PublishType -eq "internal") {
|
|
80
|
-
$feedUrl = "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js
|
|
80
|
+
$feedUrl = "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js/npm/registry"
|
|
81
81
|
|
|
82
82
|
$overrides = @{
|
|
83
83
|
"@typespec/http-client-python" = "$feedUrl/@typespec/http-client-python/-/http-client-python-$emitterVersion.tgz"
|
|
Binary file
|
|
Binary file
|
|
@@ -25,7 +25,7 @@ def _check_command_available(command: str) -> bool:
|
|
|
25
25
|
try:
|
|
26
26
|
subprocess.run([command, "--version"], capture_output=True, check=True)
|
|
27
27
|
return True
|
|
28
|
-
except (subprocess.CalledProcessError, FileNotFoundError):
|
|
28
|
+
except (subprocess.CalledProcessError, FileNotFoundError, PermissionError):
|
|
29
29
|
return False
|
|
30
30
|
|
|
31
31
|
|
|
@@ -50,7 +50,7 @@ def detect_package_manager() -> str:
|
|
|
50
50
|
try:
|
|
51
51
|
subprocess.run([sys.executable, "-m", "pip", "--version"], capture_output=True, check=True)
|
|
52
52
|
return "python -m pip"
|
|
53
|
-
except (subprocess.CalledProcessError, FileNotFoundError):
|
|
53
|
+
except (subprocess.CalledProcessError, FileNotFoundError, PermissionError):
|
|
54
54
|
pass
|
|
55
55
|
|
|
56
56
|
raise PackageManagerNotFoundError("No suitable package manager found. Please install either uv or pip.")
|
|
@@ -109,10 +109,16 @@ class _ParameterBase(BaseModel, abc.ABC): # pylint: disable=too-many-instance-a
|
|
|
109
109
|
if type_description:
|
|
110
110
|
base_description = add_to_description(base_description, type_description)
|
|
111
111
|
if self.optional and isinstance(self.type, ConstantType):
|
|
112
|
-
|
|
113
|
-
base_description
|
|
114
|
-
|
|
115
|
-
|
|
112
|
+
if self.is_api_version:
|
|
113
|
+
base_description = add_to_description(
|
|
114
|
+
base_description,
|
|
115
|
+
f"Known values are {self.get_declaration()}.",
|
|
116
|
+
)
|
|
117
|
+
else:
|
|
118
|
+
base_description = add_to_description(
|
|
119
|
+
base_description,
|
|
120
|
+
f"Known values are {self.get_declaration()} and None.",
|
|
121
|
+
)
|
|
116
122
|
if not (self.optional or self.client_default_value):
|
|
117
123
|
base_description = add_to_description(base_description, "Required.")
|
|
118
124
|
if self.client_default_value is not None:
|
|
@@ -652,6 +652,9 @@ class Model(_MyMutableMapping):
|
|
|
652
652
|
if len(items) > 0:
|
|
653
653
|
existed_attr_keys.append(xml_name)
|
|
654
654
|
dict_to_pass[rf._rest_name] = _deserialize(rf._type, items)
|
|
655
|
+
elif not rf._is_optional:
|
|
656
|
+
existed_attr_keys.append(xml_name)
|
|
657
|
+
dict_to_pass[rf._rest_name] = []
|
|
655
658
|
continue
|
|
656
659
|
|
|
657
660
|
# text element is primitive type
|
|
@@ -930,6 +933,8 @@ def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-retur
|
|
|
930
933
|
# is it optional?
|
|
931
934
|
try:
|
|
932
935
|
if any(a is _NONE_TYPE for a in annotation.__args__): # pyright: ignore
|
|
936
|
+
if rf:
|
|
937
|
+
rf._is_optional = True
|
|
933
938
|
if len(annotation.__args__) <= 2: # pyright: ignore
|
|
934
939
|
if_obj_deserializer = _get_deserialize_callable_from_annotation(
|
|
935
940
|
next(a for a in annotation.__args__ if a is not _NONE_TYPE), module, rf # pyright: ignore
|
|
@@ -1090,9 +1095,7 @@ def _failsafe_deserialize_xml(
|
|
|
1090
1095
|
return None
|
|
1091
1096
|
|
|
1092
1097
|
|
|
1093
|
-
{% if code_model.has_padded_model_property %}
|
|
1094
1098
|
# pylint: disable=too-many-instance-attributes
|
|
1095
|
-
{% endif %}
|
|
1096
1099
|
class _RestField:
|
|
1097
1100
|
def __init__(
|
|
1098
1101
|
self,
|
|
@@ -1115,6 +1118,7 @@ class _RestField:
|
|
|
1115
1118
|
self._is_discriminator = is_discriminator
|
|
1116
1119
|
self._visibility = visibility
|
|
1117
1120
|
self._is_model = False
|
|
1121
|
+
self._is_optional = False
|
|
1118
1122
|
self._default = default
|
|
1119
1123
|
self._format = format
|
|
1120
1124
|
self._is_multipart_file_input = is_multipart_file_input
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
# license information.
|
|
5
5
|
# --------------------------------------------------------------------------
|
|
6
6
|
"""The preprocessing autorest plugin."""
|
|
7
|
+
|
|
7
8
|
import copy
|
|
8
9
|
from typing import Callable, Any, Optional
|
|
9
10
|
|
|
@@ -21,7 +22,6 @@ from ..utils import (
|
|
|
21
22
|
get_body_type_for_description,
|
|
22
23
|
JSON_REGEXP,
|
|
23
24
|
KNOWN_TYPES,
|
|
24
|
-
update_enum_value,
|
|
25
25
|
)
|
|
26
26
|
|
|
27
27
|
|
|
@@ -267,30 +267,18 @@ class PreProcessPlugin(YamlUpdatePlugin):
|
|
|
267
267
|
add_redefined_builtin_info(property["clientName"], property)
|
|
268
268
|
if type.get("name"):
|
|
269
269
|
pad_type = PadType.MODEL if type["type"] == "model" else PadType.ENUM_CLASS
|
|
270
|
-
|
|
271
|
-
|
|
270
|
+
if type["type"] != "enumvalue":
|
|
271
|
+
name = self.pad_reserved_words(type["name"], pad_type, type)
|
|
272
|
+
type["name"] = name[0].upper() + name[1:]
|
|
272
273
|
type["description"] = update_description(type.get("description", ""), type["name"])
|
|
273
274
|
type["snakeCaseName"] = to_snake_case(type["name"])
|
|
274
275
|
if type.get("values"):
|
|
275
|
-
# we're enums
|
|
276
|
-
values_to_add = []
|
|
276
|
+
# we're enums - enum values are UPPER_CASE so no padding needed for reserved words
|
|
277
277
|
for value in type["values"]:
|
|
278
|
-
|
|
279
|
-
if
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
value["name"] = padded_name
|
|
283
|
-
else:
|
|
284
|
-
if value["name"] != padded_name:
|
|
285
|
-
values_to_add.append(
|
|
286
|
-
update_enum_value(
|
|
287
|
-
name=padded_name,
|
|
288
|
-
value=value["value"],
|
|
289
|
-
description=value["description"],
|
|
290
|
-
enum_type=value["enumType"],
|
|
291
|
-
)
|
|
292
|
-
)
|
|
293
|
-
type["values"].extend(values_to_add)
|
|
278
|
+
upper_name = value["name"].upper()
|
|
279
|
+
if upper_name[0] in "0123456789":
|
|
280
|
+
upper_name = "ENUM_" + upper_name
|
|
281
|
+
value["name"] = upper_name
|
|
294
282
|
|
|
295
283
|
# add type for reference
|
|
296
284
|
for v in HEADERS_CONVERT_IN_METHOD.values():
|
|
@@ -56,7 +56,6 @@ class PadType(str, Enum):
|
|
|
56
56
|
ENUM_CLASS = "Enum"
|
|
57
57
|
METHOD = "_method"
|
|
58
58
|
PARAMETER = "_parameter"
|
|
59
|
-
ENUM_VALUE = "_enum"
|
|
60
59
|
PROPERTY = "_property"
|
|
61
60
|
OPERATION_GROUP = "Operations"
|
|
62
61
|
|
|
@@ -183,7 +182,6 @@ RESERVED_WORDS = {
|
|
|
183
182
|
PadType.MODEL: ["enum", *_always_reserved],
|
|
184
183
|
PadType.PROPERTY: ["self", *_always_reserved],
|
|
185
184
|
PadType.ENUM_CLASS: ["enum", *_always_reserved],
|
|
186
|
-
PadType.ENUM_VALUE: ["mro", *_always_reserved],
|
|
187
185
|
PadType.OPERATION_GROUP: [*_always_reserved],
|
|
188
186
|
}
|
|
189
187
|
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
"install": [
|
|
5
5
|
{
|
|
6
6
|
"download_info": {
|
|
7
|
-
"url": "https://files.pythonhosted.org/packages/
|
|
7
|
+
"url": "https://files.pythonhosted.org/packages/9d/76/f789f7a86709c6b087c5a2f52f911838cad707cc613162401badc665acfe/setuptools-82.0.1-py3-none-any.whl",
|
|
8
8
|
"archive_info": {
|
|
9
|
-
"hash": "sha256=
|
|
9
|
+
"hash": "sha256=a59e362652f08dcd477c78bb6e7bd9d80a7995bc73ce773050228a348ce2e5bb",
|
|
10
10
|
"hashes": {
|
|
11
|
-
"sha256": "
|
|
11
|
+
"sha256": "a59e362652f08dcd477c78bb6e7bd9d80a7995bc73ce773050228a348ce2e5bb"
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
},
|
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
"metadata": {
|
|
19
19
|
"metadata_version": "2.4",
|
|
20
20
|
"name": "setuptools",
|
|
21
|
-
"version": "82.0.
|
|
21
|
+
"version": "82.0.1",
|
|
22
22
|
"dynamic": [
|
|
23
23
|
"license-file"
|
|
24
24
|
],
|
|
25
|
-
"summary": "
|
|
25
|
+
"summary": "Most extensible Python build backend with support for C/C++ extension modules",
|
|
26
26
|
"description": ".. |pypi-version| image:: https://img.shields.io/pypi/v/setuptools.svg\n :target: https://pypi.org/project/setuptools\n\n.. |py-version| image:: https://img.shields.io/pypi/pyversions/setuptools.svg\n\n.. |test-badge| image:: https://github.com/pypa/setuptools/actions/workflows/main.yml/badge.svg\n :target: https://github.com/pypa/setuptools/actions?query=workflow%3A%22tests%22\n :alt: tests\n\n.. |ruff-badge| image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json\n :target: https://github.com/astral-sh/ruff\n :alt: Ruff\n\n.. |docs-badge| image:: https://img.shields.io/readthedocs/setuptools/latest.svg\n :target: https://setuptools.pypa.io\n\n.. |skeleton-badge| image:: https://img.shields.io/badge/skeleton-2025-informational\n :target: https://blog.jaraco.com/skeleton\n\n.. |codecov-badge| image:: https://img.shields.io/codecov/c/github/pypa/setuptools/master.svg?logo=codecov&logoColor=white\n :target: https://codecov.io/gh/pypa/setuptools\n\n.. |tidelift-badge| image:: https://tidelift.com/badges/github/pypa/setuptools?style=flat\n :target: https://tidelift.com/subscription/pkg/pypi-setuptools?utm_source=pypi-setuptools&utm_medium=readme\n\n.. |discord-badge| image:: https://img.shields.io/discord/803025117553754132\n :target: https://discord.com/channels/803025117553754132/815945031150993468\n :alt: Discord\n\n|pypi-version| |py-version| |test-badge| |ruff-badge| |docs-badge| |skeleton-badge| |codecov-badge| |discord-badge|\n\nSee the `Quickstart <https://setuptools.pypa.io/en/latest/userguide/quickstart.html>`_\nand the `User's Guide <https://setuptools.pypa.io/en/latest/userguide/>`_ for\ninstructions on how to use Setuptools.\n\nQuestions and comments should be directed to `GitHub Discussions\n<https://github.com/pypa/setuptools/discussions>`_.\nBug reports and especially tested patches may be\nsubmitted directly to the `bug tracker\n<https://github.com/pypa/setuptools/issues>`_.\n\n\nCode of Conduct\n===============\n\nEveryone interacting in the setuptools project's codebases, issue trackers,\nchat rooms, and fora is expected to follow the\n`PSF Code of Conduct <https://github.com/pypa/.github/blob/main/CODE_OF_CONDUCT.md>`_.\n\n\nFor Enterprise\n==============\n\nAvailable as part of the Tidelift Subscription.\n\nSetuptools and the maintainers of thousands of other packages are working with Tidelift to deliver one enterprise subscription that covers all of the open source you use.\n\n`Learn more <https://tidelift.com/subscription/pkg/pypi-setuptools?utm_source=pypi-setuptools&utm_medium=referral&utm_campaign=github>`_.\n",
|
|
27
27
|
"description_content_type": "text/x-rst",
|
|
28
28
|
"keywords": [
|
|
@@ -88,7 +88,6 @@
|
|
|
88
88
|
"importlib_metadata>=6; python_version < \"3.10\" and extra == \"core\"",
|
|
89
89
|
"tomli>=2.0.1; python_version < \"3.11\" and extra == \"core\"",
|
|
90
90
|
"wheel>=0.43.0; extra == \"core\"",
|
|
91
|
-
"platformdirs>=4.2.2; extra == \"core\"",
|
|
92
91
|
"jaraco.functools>=4; extra == \"core\"",
|
|
93
92
|
"more_itertools; extra == \"core\"",
|
|
94
93
|
"pytest-checkdocs>=2.4; extra == \"check\"",
|
|
Binary file
|
|
@@ -109,10 +109,16 @@ class _ParameterBase(BaseModel, abc.ABC): # pylint: disable=too-many-instance-a
|
|
|
109
109
|
if type_description:
|
|
110
110
|
base_description = add_to_description(base_description, type_description)
|
|
111
111
|
if self.optional and isinstance(self.type, ConstantType):
|
|
112
|
-
|
|
113
|
-
base_description
|
|
114
|
-
|
|
115
|
-
|
|
112
|
+
if self.is_api_version:
|
|
113
|
+
base_description = add_to_description(
|
|
114
|
+
base_description,
|
|
115
|
+
f"Known values are {self.get_declaration()}.",
|
|
116
|
+
)
|
|
117
|
+
else:
|
|
118
|
+
base_description = add_to_description(
|
|
119
|
+
base_description,
|
|
120
|
+
f"Known values are {self.get_declaration()} and None.",
|
|
121
|
+
)
|
|
116
122
|
if not (self.optional or self.client_default_value):
|
|
117
123
|
base_description = add_to_description(base_description, "Required.")
|
|
118
124
|
if self.client_default_value is not None:
|
|
@@ -652,6 +652,9 @@ class Model(_MyMutableMapping):
|
|
|
652
652
|
if len(items) > 0:
|
|
653
653
|
existed_attr_keys.append(xml_name)
|
|
654
654
|
dict_to_pass[rf._rest_name] = _deserialize(rf._type, items)
|
|
655
|
+
elif not rf._is_optional:
|
|
656
|
+
existed_attr_keys.append(xml_name)
|
|
657
|
+
dict_to_pass[rf._rest_name] = []
|
|
655
658
|
continue
|
|
656
659
|
|
|
657
660
|
# text element is primitive type
|
|
@@ -930,6 +933,8 @@ def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-retur
|
|
|
930
933
|
# is it optional?
|
|
931
934
|
try:
|
|
932
935
|
if any(a is _NONE_TYPE for a in annotation.__args__): # pyright: ignore
|
|
936
|
+
if rf:
|
|
937
|
+
rf._is_optional = True
|
|
933
938
|
if len(annotation.__args__) <= 2: # pyright: ignore
|
|
934
939
|
if_obj_deserializer = _get_deserialize_callable_from_annotation(
|
|
935
940
|
next(a for a in annotation.__args__ if a is not _NONE_TYPE), module, rf # pyright: ignore
|
|
@@ -1090,9 +1095,7 @@ def _failsafe_deserialize_xml(
|
|
|
1090
1095
|
return None
|
|
1091
1096
|
|
|
1092
1097
|
|
|
1093
|
-
{% if code_model.has_padded_model_property %}
|
|
1094
1098
|
# pylint: disable=too-many-instance-attributes
|
|
1095
|
-
{% endif %}
|
|
1096
1099
|
class _RestField:
|
|
1097
1100
|
def __init__(
|
|
1098
1101
|
self,
|
|
@@ -1115,6 +1118,7 @@ class _RestField:
|
|
|
1115
1118
|
self._is_discriminator = is_discriminator
|
|
1116
1119
|
self._visibility = visibility
|
|
1117
1120
|
self._is_model = False
|
|
1121
|
+
self._is_optional = False
|
|
1118
1122
|
self._default = default
|
|
1119
1123
|
self._format = format
|
|
1120
1124
|
self._is_multipart_file_input = is_multipart_file_input
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
# license information.
|
|
5
5
|
# --------------------------------------------------------------------------
|
|
6
6
|
"""The preprocessing autorest plugin."""
|
|
7
|
+
|
|
7
8
|
import copy
|
|
8
9
|
from typing import Callable, Any, Optional
|
|
9
10
|
|
|
@@ -21,7 +22,6 @@ from ..utils import (
|
|
|
21
22
|
get_body_type_for_description,
|
|
22
23
|
JSON_REGEXP,
|
|
23
24
|
KNOWN_TYPES,
|
|
24
|
-
update_enum_value,
|
|
25
25
|
)
|
|
26
26
|
|
|
27
27
|
|
|
@@ -267,30 +267,18 @@ class PreProcessPlugin(YamlUpdatePlugin):
|
|
|
267
267
|
add_redefined_builtin_info(property["clientName"], property)
|
|
268
268
|
if type.get("name"):
|
|
269
269
|
pad_type = PadType.MODEL if type["type"] == "model" else PadType.ENUM_CLASS
|
|
270
|
-
|
|
271
|
-
|
|
270
|
+
if type["type"] != "enumvalue":
|
|
271
|
+
name = self.pad_reserved_words(type["name"], pad_type, type)
|
|
272
|
+
type["name"] = name[0].upper() + name[1:]
|
|
272
273
|
type["description"] = update_description(type.get("description", ""), type["name"])
|
|
273
274
|
type["snakeCaseName"] = to_snake_case(type["name"])
|
|
274
275
|
if type.get("values"):
|
|
275
|
-
# we're enums
|
|
276
|
-
values_to_add = []
|
|
276
|
+
# we're enums - enum values are UPPER_CASE so no padding needed for reserved words
|
|
277
277
|
for value in type["values"]:
|
|
278
|
-
|
|
279
|
-
if
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
value["name"] = padded_name
|
|
283
|
-
else:
|
|
284
|
-
if value["name"] != padded_name:
|
|
285
|
-
values_to_add.append(
|
|
286
|
-
update_enum_value(
|
|
287
|
-
name=padded_name,
|
|
288
|
-
value=value["value"],
|
|
289
|
-
description=value["description"],
|
|
290
|
-
enum_type=value["enumType"],
|
|
291
|
-
)
|
|
292
|
-
)
|
|
293
|
-
type["values"].extend(values_to_add)
|
|
278
|
+
upper_name = value["name"].upper()
|
|
279
|
+
if upper_name[0] in "0123456789":
|
|
280
|
+
upper_name = "ENUM_" + upper_name
|
|
281
|
+
value["name"] = upper_name
|
|
294
282
|
|
|
295
283
|
# add type for reference
|
|
296
284
|
for v in HEADERS_CONVERT_IN_METHOD.values():
|
|
@@ -56,7 +56,6 @@ class PadType(str, Enum):
|
|
|
56
56
|
ENUM_CLASS = "Enum"
|
|
57
57
|
METHOD = "_method"
|
|
58
58
|
PARAMETER = "_parameter"
|
|
59
|
-
ENUM_VALUE = "_enum"
|
|
60
59
|
PROPERTY = "_property"
|
|
61
60
|
OPERATION_GROUP = "Operations"
|
|
62
61
|
|
|
@@ -183,7 +182,6 @@ RESERVED_WORDS = {
|
|
|
183
182
|
PadType.MODEL: ["enum", *_always_reserved],
|
|
184
183
|
PadType.PROPERTY: ["self", *_always_reserved],
|
|
185
184
|
PadType.ENUM_CLASS: ["enum", *_always_reserved],
|
|
186
|
-
PadType.ENUM_VALUE: ["mro", *_always_reserved],
|
|
187
185
|
PadType.OPERATION_GROUP: [*_always_reserved],
|
|
188
186
|
}
|
|
189
187
|
|
|
@@ -6,10 +6,13 @@
|
|
|
6
6
|
import pytest
|
|
7
7
|
from specs.azure.clientgenerator.core.flattenproperty.aio import FlattenPropertyClient
|
|
8
8
|
from specs.azure.clientgenerator.core.flattenproperty.models import (
|
|
9
|
-
|
|
9
|
+
ChildFlattenModel,
|
|
10
10
|
ChildModel,
|
|
11
|
+
FlattenModel,
|
|
12
|
+
FlattenUnknownModel,
|
|
11
13
|
NestedFlattenModel,
|
|
12
|
-
|
|
14
|
+
Solution,
|
|
15
|
+
SolutionProperties,
|
|
13
16
|
)
|
|
14
17
|
|
|
15
18
|
|
|
@@ -46,6 +49,25 @@ async def test_put_nested_flatten_model(client: FlattenPropertyClient):
|
|
|
46
49
|
)
|
|
47
50
|
|
|
48
51
|
|
|
52
|
+
@pytest.mark.asyncio
|
|
53
|
+
async def test_put_flatten_unknown_model(client: FlattenPropertyClient):
|
|
54
|
+
result = await client.put_flatten_unknown_model(FlattenUnknownModel(name="foo"))
|
|
55
|
+
assert result.name == "test"
|
|
56
|
+
assert result.properties == {"key1": "value1", "key2": "value2"}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
@pytest.mark.asyncio
|
|
60
|
+
async def test_put_flatten_read_only_model(client: FlattenPropertyClient):
|
|
61
|
+
result = await client.put_flatten_read_only_model(Solution(name="foo"))
|
|
62
|
+
assert result == Solution(
|
|
63
|
+
name="foo",
|
|
64
|
+
properties=SolutionProperties(solution_id="solution1", title="Solution Title", content="Solution Content"),
|
|
65
|
+
)
|
|
66
|
+
assert result.solution_id == "solution1"
|
|
67
|
+
assert result.title == "Solution Title"
|
|
68
|
+
assert result.content == "Solution Content"
|
|
69
|
+
|
|
70
|
+
|
|
49
71
|
@pytest.mark.asyncio # ============test for compatibility ============
|
|
50
72
|
async def test_dpg_model_common():
|
|
51
73
|
flatten_model = FlattenModel(name="hello", properties=ChildModel(age=0, description="test"))
|
|
@@ -16,17 +16,17 @@ async def client():
|
|
|
16
16
|
|
|
17
17
|
@pytest.mark.asyncio
|
|
18
18
|
async def test_client(client: NamingClient):
|
|
19
|
-
await client.client(models.ClientNameModel(client_name=True))
|
|
19
|
+
await client.property.client(models.ClientNameModel(client_name=True))
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
@pytest.mark.asyncio
|
|
23
23
|
async def test_language(client: NamingClient):
|
|
24
|
-
await client.language(models.LanguageClientNameModel(python_name=True))
|
|
24
|
+
await client.property.language(models.LanguageClientNameModel(python_name=True))
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
@pytest.mark.asyncio
|
|
28
28
|
async def test_compatible_with_encoded_name(client: NamingClient):
|
|
29
|
-
await client.compatible_with_encoded_name(models.ClientNameAndJsonEncodedNameModel(client_name=True))
|
|
29
|
+
await client.property.compatible_with_encoded_name(models.ClientNameAndJsonEncodedNameModel(client_name=True))
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
@pytest.mark.asyncio
|
|
@@ -41,12 +41,12 @@ async def test_parameter(client: NamingClient):
|
|
|
41
41
|
|
|
42
42
|
@pytest.mark.asyncio
|
|
43
43
|
async def test_header_request(client: NamingClient):
|
|
44
|
-
await client.request(client_name="true")
|
|
44
|
+
await client.header.request(client_name="true")
|
|
45
45
|
|
|
46
46
|
|
|
47
47
|
@pytest.mark.asyncio
|
|
48
48
|
async def test_header_response(client: NamingClient):
|
|
49
|
-
assert (await client.response(cls=lambda x, y, z: z))["default-name"] == "true"
|
|
49
|
+
assert (await client.header.response(cls=lambda x, y, z: z))["default-name"] == "true"
|
|
50
50
|
|
|
51
51
|
|
|
52
52
|
@pytest.mark.asyncio
|
|
@@ -38,6 +38,7 @@ async def test_structure_multiclient():
|
|
|
38
38
|
await client_b.renamed_six()
|
|
39
39
|
|
|
40
40
|
|
|
41
|
+
@pytest.mark.skip(reason="will reopen the cases after upgrade `@azure-tools/typespec-client-generator-core` to 0.67.0")
|
|
41
42
|
@pytest.mark.asyncio
|
|
42
43
|
async def test_structure_renamed_operation():
|
|
43
44
|
client = RenamedOperationClient(endpoint="http://localhost:3000", client=ClientType.RENAMED_OPERATION)
|
|
@@ -45,18 +46,19 @@ async def test_structure_renamed_operation():
|
|
|
45
46
|
await client.renamed_three()
|
|
46
47
|
await client.renamed_five()
|
|
47
48
|
|
|
48
|
-
await client.
|
|
49
|
-
await client.
|
|
50
|
-
await client.
|
|
49
|
+
await client.renamed_two()
|
|
50
|
+
await client.renamed_four()
|
|
51
|
+
await client.renamed_six()
|
|
51
52
|
|
|
52
53
|
|
|
54
|
+
@pytest.mark.skip(reason="will reopen the cases after upgrade `@azure-tools/typespec-client-generator-core` to 0.67.0")
|
|
53
55
|
@pytest.mark.asyncio
|
|
54
56
|
async def test_structure_two_operation_group():
|
|
55
|
-
client = TwoOperationGroupClient(endpoint="http://localhost:3000", client=ClientType.
|
|
56
|
-
await client.
|
|
57
|
-
await client.
|
|
58
|
-
await client.
|
|
59
|
-
|
|
60
|
-
await client.
|
|
61
|
-
await client.
|
|
62
|
-
await client.
|
|
57
|
+
client = TwoOperationGroupClient(endpoint="http://localhost:3000", client=ClientType.TWO_OPERATION_GROUP)
|
|
58
|
+
await client.one()
|
|
59
|
+
await client.three()
|
|
60
|
+
await client.four()
|
|
61
|
+
|
|
62
|
+
await client.two()
|
|
63
|
+
await client.five()
|
|
64
|
+
await client.six()
|
|
@@ -8,22 +8,24 @@ from client.structure.clientoperationgroup.models import ClientType
|
|
|
8
8
|
from client.structure.clientoperationgroup.aio import FirstClient, SecondClient
|
|
9
9
|
|
|
10
10
|
|
|
11
|
+
@pytest.mark.skip(reason="will reopen the cases after upgrade `@azure-tools/typespec-client-generator-core` to 0.67.0")
|
|
11
12
|
@pytest.mark.asyncio
|
|
12
13
|
async def test_first_client_operations():
|
|
13
14
|
client = FirstClient(endpoint="http://localhost:3000", client=ClientType.CLIENT_OPERATION_GROUP)
|
|
14
15
|
|
|
15
16
|
await client.one()
|
|
16
17
|
|
|
17
|
-
await client.
|
|
18
|
-
await client.
|
|
18
|
+
await client.two()
|
|
19
|
+
await client.three()
|
|
19
20
|
|
|
20
|
-
await client.
|
|
21
|
+
await client.four()
|
|
21
22
|
|
|
22
23
|
|
|
24
|
+
@pytest.mark.skip(reason="will reopen the cases after upgrade `@azure-tools/typespec-client-generator-core` to 0.67.0")
|
|
23
25
|
@pytest.mark.asyncio
|
|
24
26
|
async def test_second_client_operations():
|
|
25
27
|
client = SecondClient(endpoint="http://localhost:3000", client=ClientType.CLIENT_OPERATION_GROUP)
|
|
26
28
|
|
|
27
29
|
await client.five()
|
|
28
30
|
|
|
29
|
-
await client.
|
|
31
|
+
await client.six()
|
|
@@ -63,3 +63,9 @@ async def test_model_properties_dict_methods(client: SpecialWordsClient):
|
|
|
63
63
|
@pytest.mark.asyncio
|
|
64
64
|
async def test_model_properties_with_list(client: SpecialWordsClient):
|
|
65
65
|
await client.model_properties.with_list(models.ModelWithList(list="ok"))
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
@pytest.mark.asyncio
|
|
69
|
+
async def test_extensible_strings(client: SpecialWordsClient):
|
|
70
|
+
for enum_value in models.ExtensibleString:
|
|
71
|
+
assert enum_value == await client.extensible_strings.put_extensible_string_value(body=enum_value)
|
|
@@ -6,10 +6,13 @@
|
|
|
6
6
|
import pytest
|
|
7
7
|
from specs.azure.clientgenerator.core.flattenproperty import FlattenPropertyClient
|
|
8
8
|
from specs.azure.clientgenerator.core.flattenproperty.models import (
|
|
9
|
-
|
|
9
|
+
ChildFlattenModel,
|
|
10
10
|
ChildModel,
|
|
11
|
+
FlattenModel,
|
|
12
|
+
FlattenUnknownModel,
|
|
11
13
|
NestedFlattenModel,
|
|
12
|
-
|
|
14
|
+
Solution,
|
|
15
|
+
SolutionProperties,
|
|
13
16
|
)
|
|
14
17
|
|
|
15
18
|
|
|
@@ -41,6 +44,23 @@ def test_put_nested_flatten_model(client: FlattenPropertyClient):
|
|
|
41
44
|
)
|
|
42
45
|
|
|
43
46
|
|
|
47
|
+
def test_put_flatten_unknown_model(client: FlattenPropertyClient):
|
|
48
|
+
result = client.put_flatten_unknown_model(FlattenUnknownModel(name="foo"))
|
|
49
|
+
assert result.name == "test"
|
|
50
|
+
assert result.properties == {"key1": "value1", "key2": "value2"}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def test_put_flatten_read_only_model(client: FlattenPropertyClient):
|
|
54
|
+
result = client.put_flatten_read_only_model(Solution(name="foo"))
|
|
55
|
+
assert result == Solution(
|
|
56
|
+
name="foo",
|
|
57
|
+
properties=SolutionProperties(solution_id="solution1", title="Solution Title", content="Solution Content"),
|
|
58
|
+
)
|
|
59
|
+
assert result.solution_id == "solution1"
|
|
60
|
+
assert result.title == "Solution Title"
|
|
61
|
+
assert result.content == "Solution Content"
|
|
62
|
+
|
|
63
|
+
|
|
44
64
|
# ============test for compatibility ============
|
|
45
65
|
def test_dpg_model_common():
|
|
46
66
|
flatten_model = FlattenModel(name="hello", properties=ChildModel(age=0, description="test"))
|
|
@@ -14,15 +14,15 @@ def client():
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
def test_client(client: NamingClient):
|
|
17
|
-
client.client(models.ClientNameModel(client_name=True))
|
|
17
|
+
client.property.client(models.ClientNameModel(client_name=True))
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
def test_language(client: NamingClient):
|
|
21
|
-
client.language(models.LanguageClientNameModel(python_name=True))
|
|
21
|
+
client.property.language(models.LanguageClientNameModel(python_name=True))
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
def test_compatible_with_encoded_name(client: NamingClient):
|
|
25
|
-
client.compatible_with_encoded_name(models.ClientNameAndJsonEncodedNameModel(client_name=True))
|
|
25
|
+
client.property.compatible_with_encoded_name(models.ClientNameAndJsonEncodedNameModel(client_name=True))
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
def test_operation(client: NamingClient):
|
|
@@ -34,11 +34,11 @@ def test_parameter(client: NamingClient):
|
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
def test_header_request(client: NamingClient):
|
|
37
|
-
client.request(client_name="true")
|
|
37
|
+
client.header.request(client_name="true")
|
|
38
38
|
|
|
39
39
|
|
|
40
40
|
def test_header_response(client: NamingClient):
|
|
41
|
-
assert client.response(cls=lambda x, y, z: z)["default-name"] == "true"
|
|
41
|
+
assert client.header.response(cls=lambda x, y, z: z)["default-name"] == "true"
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
def test_model_client(client: NamingClient):
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
# Licensed under the MIT License. See License.txt in the project root for
|
|
4
4
|
# license information.
|
|
5
5
|
# --------------------------------------------------------------------------
|
|
6
|
+
import pytest
|
|
6
7
|
from client.structure.service.models import ClientType
|
|
7
8
|
from client.structure.service import ServiceClient
|
|
8
9
|
from client.structure.multiclient import ClientAClient, ClientBClient
|
|
@@ -35,23 +36,25 @@ def test_structure_multiclient():
|
|
|
35
36
|
client_b.renamed_six()
|
|
36
37
|
|
|
37
38
|
|
|
39
|
+
@pytest.mark.skip(reason="will reopen the cases after upgrade `@azure-tools/typespec-client-generator-core` to 0.67.0")
|
|
38
40
|
def test_structure_renamed_operation():
|
|
39
41
|
client = RenamedOperationClient(endpoint="http://localhost:3000", client=ClientType.RENAMED_OPERATION)
|
|
40
42
|
client.renamed_one()
|
|
41
43
|
client.renamed_three()
|
|
42
44
|
client.renamed_five()
|
|
43
45
|
|
|
44
|
-
client.
|
|
45
|
-
client.
|
|
46
|
-
client.
|
|
46
|
+
client.renamed_two()
|
|
47
|
+
client.renamed_four()
|
|
48
|
+
client.renamed_six()
|
|
47
49
|
|
|
48
50
|
|
|
51
|
+
@pytest.mark.skip(reason="will reopen the cases after upgrade `@azure-tools/typespec-client-generator-core` to 0.67.0")
|
|
49
52
|
def test_structure_two_operation_group():
|
|
50
53
|
client = TwoOperationGroupClient(endpoint="http://localhost:3000", client=ClientType.TWO_OPERATION_GROUP)
|
|
51
|
-
client.
|
|
52
|
-
client.
|
|
53
|
-
client.
|
|
54
|
+
client.one()
|
|
55
|
+
client.three()
|
|
56
|
+
client.four()
|
|
54
57
|
|
|
55
|
-
client.
|
|
56
|
-
client.
|
|
57
|
-
client.
|
|
58
|
+
client.two()
|
|
59
|
+
client.five()
|
|
60
|
+
client.six()
|
|
@@ -3,24 +3,27 @@
|
|
|
3
3
|
# Licensed under the MIT License. See License.txt in the project root for
|
|
4
4
|
# license information.
|
|
5
5
|
# --------------------------------------------------------------------------
|
|
6
|
+
import pytest
|
|
6
7
|
from client.structure.clientoperationgroup.models import ClientType
|
|
7
8
|
from client.structure.clientoperationgroup import FirstClient, SecondClient
|
|
8
9
|
|
|
9
10
|
|
|
11
|
+
@pytest.mark.skip(reason="will reopen the cases after upgrade `@azure-tools/typespec-client-generator-core` to 0.67.0")
|
|
10
12
|
def test_first_client_operations():
|
|
11
13
|
client = FirstClient(endpoint="http://localhost:3000", client=ClientType.CLIENT_OPERATION_GROUP)
|
|
12
14
|
|
|
13
15
|
client.one()
|
|
14
16
|
|
|
15
|
-
client.
|
|
16
|
-
client.
|
|
17
|
+
client.two()
|
|
18
|
+
client.three()
|
|
17
19
|
|
|
18
|
-
client.
|
|
20
|
+
client.four()
|
|
19
21
|
|
|
20
22
|
|
|
23
|
+
@pytest.mark.skip(reason="will reopen the cases after upgrade `@azure-tools/typespec-client-generator-core` to 0.67.0")
|
|
21
24
|
def test_second_client_operations():
|
|
22
25
|
client = SecondClient(endpoint="http://localhost:3000", client=ClientType.CLIENT_OPERATION_GROUP)
|
|
23
26
|
|
|
24
27
|
client.five()
|
|
25
28
|
|
|
26
|
-
client.
|
|
29
|
+
client.six()
|