@typespec/http-client-python 0.19.1 → 0.20.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/dist/emitter/emitter.js +21 -7
- package/dist/emitter/emitter.js.map +1 -1
- package/dist/emitter/http.js +8 -0
- package/dist/emitter/http.js.map +1 -1
- package/dist/emitter/utils.d.ts.map +1 -1
- package/dist/emitter/utils.js +4 -0
- package/dist/emitter/utils.js.map +1 -1
- package/emitter/src/emitter.ts +26 -7
- package/emitter/src/http.ts +8 -0
- package/emitter/src/utils.ts +4 -0
- package/emitter/temp/tsconfig.tsbuildinfo +1 -1
- package/eng/scripts/ci/conf.py +57 -0
- package/eng/scripts/ci/pyproject.toml +1 -1
- package/eng/scripts/ci/regenerate.ts +24 -0
- package/eng/scripts/ci/run_sphinx_build.py +117 -0
- package/eng/scripts/setup/__pycache__/package_manager.cpython-311.pyc +0 -0
- package/eng/scripts/setup/__pycache__/venvtools.cpython-311.pyc +0 -0
- package/generator/build/lib/pygen/__init__.py +15 -0
- package/generator/build/lib/pygen/codegen/models/operation.py +3 -3
- package/generator/build/lib/pygen/codegen/serializers/__init__.py +19 -2
- package/generator/build/lib/pygen/codegen/serializers/builder_serializer.py +29 -12
- package/generator/build/lib/pygen/codegen/serializers/parameter_serializer.py +3 -1
- package/generator/build/lib/pygen/codegen/templates/macros.jinja2 +33 -15
- package/generator/build/lib/pygen/codegen/templates/model_dpg.py.jinja2 +1 -1
- package/generator/build/lib/pygen/codegen/templates/operation_tools.jinja2 +1 -15
- package/generator/component-detection-pip-report.json +6 -6
- package/generator/dist/pygen-0.1.0-py3-none-any.whl +0 -0
- package/generator/pygen/__init__.py +15 -0
- package/generator/pygen/codegen/models/operation.py +3 -3
- package/generator/pygen/codegen/serializers/__init__.py +19 -2
- package/generator/pygen/codegen/serializers/builder_serializer.py +29 -12
- package/generator/pygen/codegen/serializers/parameter_serializer.py +3 -1
- package/generator/pygen/codegen/templates/macros.jinja2 +33 -15
- package/generator/pygen/codegen/templates/model_dpg.py.jinja2 +1 -1
- package/generator/pygen/codegen/templates/operation_tools.jinja2 +1 -15
- package/generator/test/azure/mock_api_tests/asynctests/test_azure_versioning_previewversion_async.py +53 -0
- package/generator/test/azure/mock_api_tests/test_azure_versioning_previewversion.py +50 -0
- package/generator/test/azure/mock_api_tests/test_clear_output_folder.py +14 -0
- package/generator/test/azure/requirements.txt +1 -0
- package/generator/test/azure/tox.ini +16 -8
- package/generator/test/dev_requirements.txt +4 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_encode_bytes_async.py +1 -2
- package/generator/test/generic_mock_api_tests/asynctests/test_versioning_removed_async.py +16 -5
- package/generator/test/generic_mock_api_tests/test_encode_bytes.py +1 -2
- package/generator/test/generic_mock_api_tests/test_typetest_scalar.py +5 -0
- package/generator/test/generic_mock_api_tests/test_versioning_removed.py +16 -5
- package/generator/test/unbranded/tox.ini +16 -8
- package/package.json +2 -2
- package/eng/scripts/setup/__pycache__/package_manager.cpython-39.pyc +0 -0
- package/eng/scripts/setup/__pycache__/venvtools.cpython-39.pyc +0 -0
|
@@ -1053,10 +1053,13 @@ class _OperationSerializer(_BuilderBaseSerializer[OperationType]):
|
|
|
1053
1053
|
f" error = _failsafe_deserialize({type_annotation},{pylint_disable}\n response)"
|
|
1054
1054
|
)
|
|
1055
1055
|
else:
|
|
1056
|
-
retval.
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1056
|
+
retval.extend(
|
|
1057
|
+
[
|
|
1058
|
+
" error = self._deserialize.failsafe_deserialize(",
|
|
1059
|
+
f" {type_annotation},{pylint_disable}",
|
|
1060
|
+
" pipeline_response,",
|
|
1061
|
+
" )",
|
|
1062
|
+
]
|
|
1060
1063
|
)
|
|
1061
1064
|
# add build-in error type
|
|
1062
1065
|
# TODO: we should decide whether need to this wrapper for customized error type
|
|
@@ -1097,10 +1100,13 @@ class _OperationSerializer(_BuilderBaseSerializer[OperationType]):
|
|
|
1097
1100
|
f"{type_annotation},{pylint_disable}\n response)"
|
|
1098
1101
|
)
|
|
1099
1102
|
else:
|
|
1100
|
-
retval.
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1103
|
+
retval.extend(
|
|
1104
|
+
[
|
|
1105
|
+
" error = self._deserialize.failsafe_deserialize(",
|
|
1106
|
+
f" {type_annotation},{pylint_disable}",
|
|
1107
|
+
" pipeline_response,",
|
|
1108
|
+
" )",
|
|
1109
|
+
]
|
|
1104
1110
|
)
|
|
1105
1111
|
condition = "elif"
|
|
1106
1112
|
# default error handling
|
|
@@ -1111,11 +1117,22 @@ class _OperationSerializer(_BuilderBaseSerializer[OperationType]):
|
|
|
1111
1117
|
if builder.non_default_errors:
|
|
1112
1118
|
retval.append(" else:")
|
|
1113
1119
|
if self.code_model.options["models-mode"] == "dpg":
|
|
1114
|
-
retval.
|
|
1120
|
+
retval.extend(
|
|
1121
|
+
[
|
|
1122
|
+
f"{indent}error = _failsafe_deserialize(",
|
|
1123
|
+
f"{indent} {default_error_deserialization}",
|
|
1124
|
+
f"{indent} response,",
|
|
1125
|
+
f"{indent})",
|
|
1126
|
+
]
|
|
1127
|
+
)
|
|
1115
1128
|
else:
|
|
1116
|
-
retval.
|
|
1117
|
-
|
|
1118
|
-
|
|
1129
|
+
retval.extend(
|
|
1130
|
+
[
|
|
1131
|
+
f"{indent}error = self._deserialize.failsafe_deserialize(",
|
|
1132
|
+
f"{indent} {default_error_deserialization}",
|
|
1133
|
+
f"{indent} pipeline_response,",
|
|
1134
|
+
f"{indent})",
|
|
1135
|
+
]
|
|
1119
1136
|
)
|
|
1120
1137
|
retval.append(
|
|
1121
1138
|
" raise HttpResponseError(response=response{}{})".format(
|
|
@@ -202,9 +202,11 @@ class ParameterSerializer:
|
|
|
202
202
|
if is_content_type_optional and not type_annotation.startswith("Optional[")
|
|
203
203
|
else type_annotation
|
|
204
204
|
)
|
|
205
|
-
if kwarg.client_default_value is not None or kwarg.optional:
|
|
205
|
+
if kwarg.client_default_value is not None or kwarg.optional or kwarg.constant:
|
|
206
206
|
if check_client_input and kwarg.check_client_input:
|
|
207
207
|
default_value = f"self._config.{kwarg.client_name}"
|
|
208
|
+
elif kwarg.constant:
|
|
209
|
+
default_value = kwarg.type.get_declaration(None)
|
|
208
210
|
else:
|
|
209
211
|
default_value = kwarg.client_default_value_declaration
|
|
210
212
|
if check_kwarg_dict and (kwarg.location in [ParameterLocation.HEADER, ParameterLocation.QUERY]):
|
|
@@ -1,21 +1,39 @@
|
|
|
1
1
|
{% macro wrap_model_string(doc_string, wrap_string, suffix_string="") %}
|
|
2
|
-
{
|
|
3
|
-
{%- set
|
|
4
|
-
{
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
{%-
|
|
15
|
-
{%- set
|
|
2
|
+
{# Check if this is a sphinx documentation line that should not have extra prefix spacing #}
|
|
3
|
+
{%- set is_sphinx_doc = doc_string.strip().startswith(':ivar') or doc_string.strip().startswith(':vartype') or doc_string.strip().startswith(':param') or doc_string.strip().startswith(':type') -%}
|
|
4
|
+
{# Custom handling for bullet points - normalization is now done in preprocessing #}
|
|
5
|
+
{% set enable_custom_handling = "\n* " in doc_string or doc_string.startswith("* ") %}
|
|
6
|
+
{%- if enable_custom_handling -%}
|
|
7
|
+
{%- set lines = doc_string.split('\n') -%}
|
|
8
|
+
{%- set result_lines = [] -%}
|
|
9
|
+
{%- for line in lines -%}
|
|
10
|
+
{%- if line.startswith('* ') -%}
|
|
11
|
+
{# Handle bullet points with proper continuation alignment #}
|
|
12
|
+
{%- set bullet_content = line[2:] -%}
|
|
13
|
+
{%- set base_indent = wrap_string.lstrip('\n') -%}
|
|
14
|
+
{%- set bullet_line = base_indent + ' * ' + bullet_content -%}
|
|
15
|
+
{%- set continuation_spaces = base_indent + ' ' -%}
|
|
16
|
+
{%- set wrapped = bullet_line | wordwrap(width=95, break_long_words=False, break_on_hyphens=False, wrapstring='\n' + continuation_spaces) -%}
|
|
17
|
+
{%- set _ = result_lines.append(wrapped) -%}
|
|
18
|
+
{%- elif line.strip() -%}
|
|
19
|
+
{%- set wrapped = line.strip() | wordwrap(width=95, break_long_words=False, break_on_hyphens=False, wrapstring=wrap_string) -%}
|
|
20
|
+
{%- set _ = result_lines.append(wrapped) -%}
|
|
21
|
+
{%- else -%}
|
|
22
|
+
{%- set _ = result_lines.append('') -%}
|
|
23
|
+
{%- endif -%}
|
|
24
|
+
{%- endfor -%}
|
|
25
|
+
{%- set original_result = result_lines | join('\n') -%}
|
|
26
|
+
{%- else -%}
|
|
27
|
+
{# Regular text handling #}
|
|
28
|
+
{%- set original_result = doc_string | wordwrap(width=95, break_long_words=False, break_on_hyphens=False, wrapstring=wrap_string) -%}
|
|
29
|
+
{%- endif -%}
|
|
16
30
|
{% set list_result = original_result.split('\n') %}
|
|
17
31
|
{% for line in list_result %}
|
|
18
|
-
{
|
|
32
|
+
{%- if is_sphinx_doc and enable_custom_handling -%}
|
|
33
|
+
{%- set prefix = "" -%}
|
|
34
|
+
{%- else -%}
|
|
35
|
+
{%- set prefix = "" if loop.index == 1 else " " -%}
|
|
36
|
+
{%- endif -%}
|
|
19
37
|
{% set suffix = suffix_string if list_result | length == loop.index %}
|
|
20
38
|
{{ prefix }}{{ line }}{{ suffix }}
|
|
21
39
|
{% endfor %}
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
if key in self.__flattened_items:
|
|
79
79
|
if self.{{ flattened_property_attr }} is None:
|
|
80
80
|
self.{{ flattened_property_attr }} = self._attr_to_rest_field["{{ flattened_property_attr }}"]._class_type()
|
|
81
|
-
setattr(self.
|
|
81
|
+
setattr(self.{{ flattened_property_attr }}, key, value)
|
|
82
82
|
else:
|
|
83
83
|
super().__setattr__(key, value)
|
|
84
84
|
{% endif %}
|
|
@@ -1,18 +1,4 @@
|
|
|
1
|
-
{% macro wrap_string(string, wrapstring, width=95) %}
|
|
2
|
-
{%- set lines = string.split('\n') -%}
|
|
3
|
-
{%- set processed_lines = [] -%}
|
|
4
|
-
{%- for line in lines -%}
|
|
5
|
-
{%- set stripped = line.strip() -%}
|
|
6
|
-
{%- if stripped.startswith('* ') -%}
|
|
7
|
-
{%- set bullet_with_indent = stripped -%}
|
|
8
|
-
{%- set wrapped = bullet_with_indent | wordwrap(width=width, break_long_words=False, break_on_hyphens=False, wrapstring=wrapstring + ' ') -%}
|
|
9
|
-
{%- set _ = processed_lines.append(wrapped) -%}
|
|
10
|
-
{%- elif stripped -%}
|
|
11
|
-
{%- set wrapped = line | wordwrap(width=width, break_long_words=False, break_on_hyphens=False, wrapstring=wrapstring) -%}
|
|
12
|
-
{%- set _ = processed_lines.append(wrapped) -%}
|
|
13
|
-
{%- endif -%}
|
|
14
|
-
{%- endfor -%}
|
|
15
|
-
{{ processed_lines | join('\n') | replace("\\", "\\\\") }}{%- endmacro %}
|
|
1
|
+
{% macro wrap_string(string, wrapstring, width=95) %}{{ string | replace("\\", "\\\\") | wordwrap(width=width, break_long_words=False, break_on_hyphens=False, wrapstring=wrapstring)}}{% endmacro %}
|
|
16
2
|
|
|
17
3
|
{% macro description(builder, serializer) %}
|
|
18
4
|
{% set example_template = serializer.example_template(builder) %}
|
package/generator/test/azure/mock_api_tests/asynctests/test_azure_versioning_previewversion_async.py
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# -------------------------------------------------------------------------
|
|
2
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
# Licensed under the MIT License. See License.txt in the project root for
|
|
4
|
+
# license information.
|
|
5
|
+
# --------------------------------------------------------------------------
|
|
6
|
+
import pytest
|
|
7
|
+
from specs.azure.versioning.previewversion.aio import PreviewVersionClient
|
|
8
|
+
from specs.azure.versioning.previewversion.models import UpdateWidgetColorRequest
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@pytest.fixture
|
|
12
|
+
async def client():
|
|
13
|
+
async with PreviewVersionClient() as client:
|
|
14
|
+
yield client
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@pytest.fixture
|
|
18
|
+
async def stable_client():
|
|
19
|
+
async with PreviewVersionClient(api_version="2024-06-01") as client:
|
|
20
|
+
yield client
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@pytest.mark.asyncio
|
|
24
|
+
async def test_get_widget(client: PreviewVersionClient):
|
|
25
|
+
result = await client.get_widget(id="widget-123")
|
|
26
|
+
assert result.id == "widget-123"
|
|
27
|
+
assert result.name == "Sample Widget"
|
|
28
|
+
assert result.color == "blue"
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@pytest.mark.asyncio
|
|
32
|
+
async def test_update_widget_color(client: PreviewVersionClient):
|
|
33
|
+
color_update = UpdateWidgetColorRequest(color="red")
|
|
34
|
+
result = await client.update_widget_color(id="widget-123", color_update=color_update)
|
|
35
|
+
assert result.id == "widget-123"
|
|
36
|
+
assert result.name == "Sample Widget"
|
|
37
|
+
assert result.color == "red"
|
|
38
|
+
|
|
39
|
+
with pytest.raises(ValueError):
|
|
40
|
+
async with PreviewVersionClient(api_version="2024-06-01") as stable_client:
|
|
41
|
+
await stable_client.update_widget_color(id="widget-123", color_update=color_update)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
@pytest.mark.asyncio
|
|
45
|
+
async def test_list_widgets(stable_client: PreviewVersionClient):
|
|
46
|
+
result = await stable_client.list_widgets(name="test")
|
|
47
|
+
assert len(result.widgets) == 1
|
|
48
|
+
assert result.widgets[0].id == "widget-1"
|
|
49
|
+
assert result.widgets[0].name == "test"
|
|
50
|
+
|
|
51
|
+
with pytest.raises(ValueError):
|
|
52
|
+
async with PreviewVersionClient(api_version="2024-06-01") as client:
|
|
53
|
+
await client.list_widgets(name="test", color="test")
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# -------------------------------------------------------------------------
|
|
2
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
# Licensed under the MIT License. See License.txt in the project root for
|
|
4
|
+
# license information.
|
|
5
|
+
# --------------------------------------------------------------------------
|
|
6
|
+
import pytest
|
|
7
|
+
from specs.azure.versioning.previewversion import PreviewVersionClient
|
|
8
|
+
from specs.azure.versioning.previewversion.models import UpdateWidgetColorRequest
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@pytest.fixture
|
|
12
|
+
def client():
|
|
13
|
+
with PreviewVersionClient() as client:
|
|
14
|
+
yield client
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@pytest.fixture
|
|
18
|
+
def stable_client():
|
|
19
|
+
with PreviewVersionClient(api_version="2024-06-01") as client:
|
|
20
|
+
yield client
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def test_get_widget(client: PreviewVersionClient):
|
|
24
|
+
result = client.get_widget(id="widget-123")
|
|
25
|
+
assert result.id == "widget-123"
|
|
26
|
+
assert result.name == "Sample Widget"
|
|
27
|
+
assert result.color == "blue"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def test_update_widget_color(client: PreviewVersionClient):
|
|
31
|
+
color_update = UpdateWidgetColorRequest(color="red")
|
|
32
|
+
result = client.update_widget_color(id="widget-123", color_update=color_update)
|
|
33
|
+
assert result.id == "widget-123"
|
|
34
|
+
assert result.name == "Sample Widget"
|
|
35
|
+
assert result.color == "red"
|
|
36
|
+
|
|
37
|
+
with pytest.raises(ValueError):
|
|
38
|
+
with PreviewVersionClient(api_version="2024-06-01") as stable_client:
|
|
39
|
+
stable_client.update_widget_color(id="widget-123", color_update=color_update)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def test_list_widgets(stable_client: PreviewVersionClient):
|
|
43
|
+
result = stable_client.list_widgets(name="test")
|
|
44
|
+
assert len(result.widgets) == 1
|
|
45
|
+
assert result.widgets[0].id == "widget-1"
|
|
46
|
+
assert result.widgets[0].name == "test"
|
|
47
|
+
|
|
48
|
+
with pytest.raises(ValueError):
|
|
49
|
+
with PreviewVersionClient(api_version="2024-06-01") as client:
|
|
50
|
+
client.list_widgets(name="test", color="test")
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# -------------------------------------------------------------------------
|
|
2
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
# Licensed under the MIT License. See License.txt in the project root for
|
|
4
|
+
# license information.
|
|
5
|
+
# --------------------------------------------------------------------------
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
GENERATED_PATH = Path(__file__).parent.parent.resolve() / "generated"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def test_clear_output_folder():
|
|
12
|
+
folder = GENERATED_PATH / "authentication-api-key/authentication/apikey/_operations"
|
|
13
|
+
assert folder.exists(), "Operations folder should exist"
|
|
14
|
+
assert not (folder / "to_be_deleted.py").exists(), "File to_be_deleted.py should be deleted after regeneration"
|
|
@@ -30,6 +30,7 @@ azure-mgmt-core==1.6.0
|
|
|
30
30
|
-e ./generated/azure-resource-manager-operation-templates
|
|
31
31
|
-e ./generated/azure-resource-manager-resources
|
|
32
32
|
-e ./generated/azure-resource-manager-method-subscription-id
|
|
33
|
+
-e ./generated/azure-versioning-previewversion
|
|
33
34
|
-e ./generated/client-namespace
|
|
34
35
|
-e ./generated/azure-payload-pageable
|
|
35
36
|
-e ./generated/client-naming
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
[tox]
|
|
2
|
-
envlist=base, lint, mypy, pyright, apiview
|
|
2
|
+
envlist=base, lint, mypy, pyright, apiview, sphinx
|
|
3
3
|
skipsdist=True
|
|
4
4
|
|
|
5
5
|
[testenv:ci]
|
|
@@ -7,21 +7,22 @@ deps=
|
|
|
7
7
|
-r requirements.txt
|
|
8
8
|
commands =
|
|
9
9
|
# pytest
|
|
10
|
-
|
|
10
|
+
{[testenv:test]commands}
|
|
11
11
|
|
|
12
12
|
# pylint
|
|
13
|
-
|
|
14
|
-
python ../../../eng/scripts/ci/run_pylint.py -t azure -s "generated" {posargs}
|
|
13
|
+
{[testenv:lint]commands}
|
|
15
14
|
|
|
16
15
|
# mypy
|
|
17
|
-
|
|
16
|
+
{[testenv:mypy]commands}
|
|
18
17
|
|
|
19
18
|
# pyright
|
|
20
|
-
|
|
19
|
+
{[testenv:pyright]commands}
|
|
21
20
|
|
|
22
21
|
# apiview
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
{[testenv:apiview]commands}
|
|
23
|
+
|
|
24
|
+
# sphinx docstring validation
|
|
25
|
+
{[testenv:sphinx]commands}
|
|
25
26
|
|
|
26
27
|
[testenv:test]
|
|
27
28
|
deps=
|
|
@@ -54,3 +55,10 @@ deps=
|
|
|
54
55
|
commands =
|
|
55
56
|
pip install apiview-stub-generator==0.3.19 --index-url="https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/"
|
|
56
57
|
python ../../../eng/scripts/ci/run_apiview.py -t azure -s "generated" {posargs}
|
|
58
|
+
|
|
59
|
+
[testenv:sphinx]
|
|
60
|
+
basepython = python3.10
|
|
61
|
+
deps=
|
|
62
|
+
-r requirements.txt
|
|
63
|
+
commands =
|
|
64
|
+
python ../../../eng/scripts/ci/run_sphinx_build.py -t azure -s "generated" {posargs}
|
|
@@ -124,5 +124,4 @@ async def test_response_body(client: BytesClient, png_data: bytes):
|
|
|
124
124
|
assert expected == await client.response_body.base64()
|
|
125
125
|
assert b"".join([d async for d in (await client.response_body.octet_stream())]) == png_data
|
|
126
126
|
assert b"".join([d async for d in (await client.response_body.custom_content_type())]) == png_data
|
|
127
|
-
|
|
128
|
-
# assert expected == await client.response_body.base64_url()
|
|
127
|
+
assert expected == await client.response_body.base64_url()
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
# --------------------------------------------------------------------------
|
|
6
6
|
import pytest
|
|
7
7
|
from versioning.removed.aio import RemovedClient
|
|
8
|
-
from versioning.removed.models import ModelV2, EnumV2
|
|
8
|
+
from versioning.removed.models import ModelV2, EnumV2, ModelV3, EnumV3
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
@pytest.fixture
|
|
@@ -22,7 +22,18 @@ async def test_v2(client: RemovedClient):
|
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
@pytest.mark.asyncio
|
|
25
|
-
async def test_model_v3(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
async def test_model_v3():
|
|
26
|
+
async with RemovedClient(endpoint="http://localhost:3000", version="v1") as client1:
|
|
27
|
+
model1 = ModelV3(id="123", enum_prop=EnumV3.ENUM_MEMBER_V1)
|
|
28
|
+
result = await client1.model_v3(model1)
|
|
29
|
+
assert result == model1
|
|
30
|
+
|
|
31
|
+
async with RemovedClient(endpoint="http://localhost:3000", version="v2preview") as client2:
|
|
32
|
+
model2 = ModelV3(id="123")
|
|
33
|
+
result = await client2.model_v3(model2)
|
|
34
|
+
assert result == model2
|
|
35
|
+
|
|
36
|
+
async with RemovedClient(endpoint="http://localhost:3000", version="v2") as client3:
|
|
37
|
+
model3 = ModelV3(id="123", enum_prop=EnumV3.ENUM_MEMBER_V1)
|
|
38
|
+
result = await client3.model_v3(model3)
|
|
39
|
+
assert result == model3
|
|
@@ -119,5 +119,4 @@ def test_response_body(client: BytesClient, png_data: bytes):
|
|
|
119
119
|
assert expected == client.response_body.base64()
|
|
120
120
|
assert b"".join(client.response_body.octet_stream()) == png_data
|
|
121
121
|
assert b"".join(client.response_body.custom_content_type()) == png_data
|
|
122
|
-
|
|
123
|
-
# assert expected == client.response_body.base64_url()
|
|
122
|
+
assert expected == client.response_body.base64_url()
|
|
@@ -51,3 +51,8 @@ def test_decimal128_verify(client: ScalarClient):
|
|
|
51
51
|
def test_decimal_verify(client: ScalarClient):
|
|
52
52
|
prepare = client.decimal_verify.prepare_verify()
|
|
53
53
|
client.decimal_verify.verify(reduce(lambda x, y: x + y, prepare))
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
# open this test case after adopt new version of http-specs for https://github.com/microsoft/typespec/pull/8807
|
|
57
|
+
# def test_constant_query(client: ScalarClient):
|
|
58
|
+
# client.constant_query.post()
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
# --------------------------------------------------------------------------
|
|
6
6
|
import pytest
|
|
7
7
|
from versioning.removed import RemovedClient
|
|
8
|
-
from versioning.removed.models import ModelV2, EnumV2
|
|
8
|
+
from versioning.removed.models import ModelV2, EnumV2, ModelV3, EnumV3
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
@pytest.fixture
|
|
@@ -20,7 +20,18 @@ def test_v2(client: RemovedClient):
|
|
|
20
20
|
)
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
def test_model_v3(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
def test_model_v3():
|
|
24
|
+
client1 = RemovedClient(endpoint="http://localhost:3000", version="v1")
|
|
25
|
+
model1 = ModelV3(id="123", enum_prop=EnumV3.ENUM_MEMBER_V1)
|
|
26
|
+
result = client1.model_v3(model1)
|
|
27
|
+
assert result == model1
|
|
28
|
+
|
|
29
|
+
client2 = RemovedClient(endpoint="http://localhost:3000", version="v2preview")
|
|
30
|
+
model2 = ModelV3(id="123")
|
|
31
|
+
result = client2.model_v3(model2)
|
|
32
|
+
assert result == model2
|
|
33
|
+
|
|
34
|
+
client3 = RemovedClient(endpoint="http://localhost:3000", version="v2")
|
|
35
|
+
model3 = ModelV3(id="123", enum_prop=EnumV3.ENUM_MEMBER_V1)
|
|
36
|
+
result = client3.model_v3(model3)
|
|
37
|
+
assert result == model3
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
[tox]
|
|
2
|
-
envlist=base, lint, mypy, pyright, apiview
|
|
2
|
+
envlist=base, lint, mypy, pyright, apiview, sphinx
|
|
3
3
|
skipsdist=True
|
|
4
4
|
|
|
5
5
|
[testenv:ci]
|
|
@@ -7,21 +7,22 @@ deps=
|
|
|
7
7
|
-r requirements.txt
|
|
8
8
|
commands =
|
|
9
9
|
# pytest
|
|
10
|
-
|
|
10
|
+
{[testenv:test]commands}
|
|
11
11
|
|
|
12
12
|
# pylint
|
|
13
|
-
|
|
14
|
-
python ../../../eng/scripts/ci/run_pylint.py -t unbranded -s "generated" {posargs}
|
|
13
|
+
{[testenv:lint]commands}
|
|
15
14
|
|
|
16
15
|
# mypy
|
|
17
|
-
|
|
16
|
+
{[testenv:mypy]commands}
|
|
18
17
|
|
|
19
18
|
# pyright
|
|
20
|
-
|
|
19
|
+
{[testenv:pyright]commands}
|
|
21
20
|
|
|
22
21
|
# apiview
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
{[testenv:apiview]commands}
|
|
23
|
+
|
|
24
|
+
# sphinx docstring validation
|
|
25
|
+
{[testenv:sphinx]commands}
|
|
25
26
|
|
|
26
27
|
[testenv:test]
|
|
27
28
|
deps=
|
|
@@ -54,3 +55,10 @@ deps=
|
|
|
54
55
|
commands =
|
|
55
56
|
pip install apiview-stub-generator==0.3.19 --index-url="https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/"
|
|
56
57
|
python ../../../eng/scripts/ci/run_apiview.py -t unbranded -s "generated" {posargs}
|
|
58
|
+
|
|
59
|
+
[testenv:sphinx]
|
|
60
|
+
basepython = python3.10
|
|
61
|
+
deps=
|
|
62
|
+
-r requirements.txt
|
|
63
|
+
commands =
|
|
64
|
+
python ../../../eng/scripts/ci/run_sphinx_build.py -t unbranded -s "generated" {posargs}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typespec/http-client-python",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"author": "Microsoft Corporation",
|
|
5
5
|
"description": "TypeSpec emitter for Python SDKs",
|
|
6
6
|
"homepage": "https://typespec.io",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"@azure-tools/typespec-azure-resource-manager": "~0.61.0",
|
|
83
83
|
"@azure-tools/typespec-azure-rulesets": "~0.61.0",
|
|
84
84
|
"@azure-tools/typespec-client-generator-core": "~0.61.0",
|
|
85
|
-
"@azure-tools/azure-http-specs": "0.1.0-alpha.
|
|
85
|
+
"@azure-tools/azure-http-specs": "0.1.0-alpha.31",
|
|
86
86
|
"@typespec/compiler": "^1.5.0",
|
|
87
87
|
"@typespec/http": "^1.5.0",
|
|
88
88
|
"@typespec/openapi": "^1.5.0",
|
|
Binary file
|
|
Binary file
|