@typespec/http-client-python 0.10.0 → 0.11.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/README.md +19 -36
- package/dist/emitter/emitter.d.ts.map +1 -1
- package/dist/emitter/emitter.js +40 -5
- package/dist/emitter/emitter.js.map +1 -1
- package/dist/emitter/http.js +5 -2
- package/dist/emitter/http.js.map +1 -1
- package/dist/emitter/lib.d.ts +2 -17
- package/dist/emitter/lib.d.ts.map +1 -1
- package/dist/emitter/lib.js +0 -7
- package/dist/emitter/lib.js.map +1 -1
- package/dist/emitter/utils.d.ts.map +1 -1
- package/dist/emitter/utils.js +9 -1
- package/dist/emitter/utils.js.map +1 -1
- package/emitter/src/emitter.ts +46 -5
- package/emitter/src/http.ts +12 -2
- package/emitter/src/lib.ts +0 -7
- package/emitter/src/utils.ts +11 -1
- package/emitter/temp/tsconfig.tsbuildinfo +1 -1
- package/eng/scripts/setup/__pycache__/venvtools.cpython-39.pyc +0 -0
- package/eng/scripts/setup/install.py +1 -0
- package/eng/scripts/setup/run_tsp.py +2 -3
- package/generator/build/lib/pygen/codegen/models/code_model.py +22 -11
- package/generator/build/lib/pygen/codegen/models/imports.py +13 -9
- package/generator/build/lib/pygen/codegen/models/lro_operation.py +1 -1
- package/generator/build/lib/pygen/codegen/models/model_type.py +3 -2
- package/generator/build/lib/pygen/codegen/models/operation.py +10 -3
- package/generator/build/lib/pygen/codegen/models/operation_group.py +27 -31
- package/generator/build/lib/pygen/codegen/models/paging_operation.py +3 -1
- package/generator/build/lib/pygen/codegen/models/parameter.py +4 -1
- package/generator/build/lib/pygen/codegen/models/primitive_types.py +2 -2
- package/generator/build/lib/pygen/codegen/models/property.py +1 -1
- package/generator/build/lib/pygen/codegen/serializers/__init__.py +31 -29
- package/generator/build/lib/pygen/codegen/serializers/builder_serializer.py +1 -1
- package/generator/build/lib/pygen/codegen/serializers/general_serializer.py +37 -34
- package/generator/build/lib/pygen/codegen/serializers/model_serializer.py +4 -3
- package/generator/build/lib/pygen/codegen/serializers/parameter_serializer.py +6 -1
- package/generator/build/lib/pygen/codegen/templates/model_dpg.py.jinja2 +1 -1
- package/generator/build/lib/pygen/codegen/templates/operation_group.py.jinja2 +3 -3
- package/generator/build/lib/pygen/codegen/templates/{vendor.py.jinja2 → utils.py.jinja2} +11 -12
- package/generator/component-detection-pip-report.json +4 -5
- package/generator/dist/pygen-0.1.0-py3-none-any.whl +0 -0
- package/generator/pygen/codegen/models/code_model.py +22 -11
- package/generator/pygen/codegen/models/imports.py +13 -9
- package/generator/pygen/codegen/models/lro_operation.py +1 -1
- package/generator/pygen/codegen/models/model_type.py +3 -2
- package/generator/pygen/codegen/models/operation.py +10 -3
- package/generator/pygen/codegen/models/operation_group.py +27 -31
- package/generator/pygen/codegen/models/paging_operation.py +3 -1
- package/generator/pygen/codegen/models/parameter.py +4 -1
- package/generator/pygen/codegen/models/primitive_types.py +2 -2
- package/generator/pygen/codegen/models/property.py +1 -1
- package/generator/pygen/codegen/serializers/__init__.py +31 -29
- package/generator/pygen/codegen/serializers/builder_serializer.py +1 -1
- package/generator/pygen/codegen/serializers/general_serializer.py +37 -34
- package/generator/pygen/codegen/serializers/model_serializer.py +4 -3
- package/generator/pygen/codegen/serializers/parameter_serializer.py +6 -1
- package/generator/pygen/codegen/templates/model_dpg.py.jinja2 +1 -1
- package/generator/pygen/codegen/templates/operation_group.py.jinja2 +3 -3
- package/generator/pygen/codegen/templates/{vendor.py.jinja2 → utils.py.jinja2} +11 -12
- package/generator/pygen.egg-info/SOURCES.txt +1 -1
- package/generator/test/azure/mock_api_tests/asynctests/test_azure_client_generator_core_client_initialization_async.py +50 -0
- package/generator/test/azure/mock_api_tests/test_azure_client_generator_core_client_initialization.py +44 -0
- package/generator/test/azure/requirements.txt +3 -1
- package/generator/test/generic_mock_api_tests/asynctests/test_encode_bytes_async.py +1 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_parameters_path_async.py +24 -0
- package/generator/test/generic_mock_api_tests/asynctests/test_payload_json_merge_patch_async.py +1 -1
- package/generator/test/generic_mock_api_tests/asynctests/test_typetest_property_nullable_async.py +1 -1
- package/generator/test/generic_mock_api_tests/test_encode_bytes.py +1 -0
- package/generator/test/generic_mock_api_tests/test_parameters_path.py +22 -0
- package/generator/test/generic_mock_api_tests/test_payload_json_merge_patch.py +1 -1
- package/generator/test/generic_mock_api_tests/test_typetest_property_nullable.py +1 -1
- package/generator/test/unbranded/requirements.txt +1 -0
- package/generator/test/unittests/conftest.py +1 -0
- package/generator/test/unittests/test_model_base_serialization.py +1 -1
- package/generator/test/unittests/test_model_base_xml_serialization.py +1 -1
- package/package.json +5 -5
|
@@ -5,20 +5,19 @@
|
|
|
5
5
|
|
|
6
6
|
{{ imports }}
|
|
7
7
|
|
|
8
|
-
{% if code_model.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
):
|
|
8
|
+
{% if code_model.need_utils_mixin %}
|
|
9
|
+
|
|
10
|
+
TClient = TypeVar("TClient")
|
|
11
|
+
TConfig = TypeVar("TConfig")
|
|
12
|
+
|
|
13
|
+
class ClientMixinABC(ABC, Generic[TClient, TConfig]):
|
|
14
14
|
"""DO NOT use this class. It is for internal typing use only."""
|
|
15
|
-
_client:
|
|
16
|
-
_config:
|
|
15
|
+
_client: TClient
|
|
16
|
+
_config: TConfig
|
|
17
17
|
_serialize: "Serializer"
|
|
18
18
|
_deserialize: "Deserializer"
|
|
19
|
-
{% endfor %}
|
|
20
19
|
{% endif %}
|
|
21
|
-
{% if code_model.
|
|
20
|
+
{% if code_model.need_utils_abstract(client_namespace) %}
|
|
22
21
|
|
|
23
22
|
def raise_if_not_implemented(cls, abstract_methods):
|
|
24
23
|
not_implemented = [f for f in abstract_methods if not callable(getattr(cls, f, None))]
|
|
@@ -29,7 +28,7 @@ def raise_if_not_implemented(cls, abstract_methods):
|
|
|
29
28
|
)
|
|
30
29
|
{% endif %}
|
|
31
30
|
|
|
32
|
-
{% if code_model.
|
|
31
|
+
{% if code_model.need_utils_etag(client_namespace) %}
|
|
33
32
|
def quote_etag(etag: Optional[str]) -> Optional[str]:
|
|
34
33
|
if not etag or etag == "*":
|
|
35
34
|
return etag
|
|
@@ -59,7 +58,7 @@ def prep_if_none_match(etag: Optional[str], match_condition: Optional[MatchCondi
|
|
|
59
58
|
return "*"
|
|
60
59
|
return None
|
|
61
60
|
{% endif %}
|
|
62
|
-
{% if code_model.
|
|
61
|
+
{% if code_model.need_utils_form_data(async_mode, client_namespace) %}
|
|
63
62
|
# file-like tuple could be `(filename, IO (or bytes))` or `(filename, IO (or bytes), content_type)`
|
|
64
63
|
FileContent = Union[str, bytes, IO[str], IO[bytes]]
|
|
65
64
|
|
|
@@ -92,8 +92,8 @@ pygen/codegen/templates/serialization.py.jinja2
|
|
|
92
92
|
pygen/codegen/templates/test.py.jinja2
|
|
93
93
|
pygen/codegen/templates/testpreparer.py.jinja2
|
|
94
94
|
pygen/codegen/templates/types.py.jinja2
|
|
95
|
+
pygen/codegen/templates/utils.py.jinja2
|
|
95
96
|
pygen/codegen/templates/validation.py.jinja2
|
|
96
|
-
pygen/codegen/templates/vendor.py.jinja2
|
|
97
97
|
pygen/codegen/templates/version.py.jinja2
|
|
98
98
|
pygen/codegen/templates/packaging_templates/CHANGELOG.md.jinja2
|
|
99
99
|
pygen/codegen/templates/packaging_templates/LICENSE.jinja2
|
|
@@ -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.clientgenerator.core.clientinitialization.aio import (
|
|
8
|
+
HeaderParamClient,
|
|
9
|
+
MultipleParamsClient,
|
|
10
|
+
MixedParamsClient,
|
|
11
|
+
PathParamClient,
|
|
12
|
+
ParamAliasClient,
|
|
13
|
+
)
|
|
14
|
+
from specs.azure.clientgenerator.core.clientinitialization.models import Input
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@pytest.mark.asyncio
|
|
18
|
+
async def test_header_param_client():
|
|
19
|
+
async with HeaderParamClient("test-name-value") as client:
|
|
20
|
+
await client.with_query(id="test-id")
|
|
21
|
+
await client.with_body(Input(name="test-name"))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@pytest.mark.asyncio
|
|
25
|
+
async def test_multiple_params_client():
|
|
26
|
+
async with MultipleParamsClient("test-name-value", "us-west") as client:
|
|
27
|
+
await client.with_query(id="test-id")
|
|
28
|
+
await client.with_body(Input(name="test-name"))
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@pytest.mark.asyncio
|
|
32
|
+
async def test_mixed_params_client():
|
|
33
|
+
async with MixedParamsClient("test-name-value") as client:
|
|
34
|
+
await client.with_query(region="us-west", id="test-id")
|
|
35
|
+
await client.with_body(Input(name="test-name"), region="us-west")
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
@pytest.mark.asyncio
|
|
39
|
+
async def test_path_param_client():
|
|
40
|
+
async with PathParamClient("sample-blob") as client:
|
|
41
|
+
await client.with_query(format="text")
|
|
42
|
+
await client.get_standalone()
|
|
43
|
+
await client.delete_standalone()
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@pytest.mark.asyncio
|
|
47
|
+
async def test_param_alias_client():
|
|
48
|
+
async with ParamAliasClient("sample-blob") as client:
|
|
49
|
+
await client.with_aliased_name()
|
|
50
|
+
await client.with_original_name()
|
|
@@ -0,0 +1,44 @@
|
|
|
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 specs.azure.clientgenerator.core.clientinitialization import (
|
|
7
|
+
HeaderParamClient,
|
|
8
|
+
MultipleParamsClient,
|
|
9
|
+
MixedParamsClient,
|
|
10
|
+
PathParamClient,
|
|
11
|
+
ParamAliasClient,
|
|
12
|
+
)
|
|
13
|
+
from specs.azure.clientgenerator.core.clientinitialization.models import Input
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def test_header_param_client():
|
|
17
|
+
with HeaderParamClient("test-name-value") as client:
|
|
18
|
+
client.with_query(id="test-id")
|
|
19
|
+
client.with_body(Input(name="test-name"))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def test_multiple_params_client():
|
|
23
|
+
with MultipleParamsClient("test-name-value", "us-west") as client:
|
|
24
|
+
client.with_query(id="test-id")
|
|
25
|
+
client.with_body(Input(name="test-name"))
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def test_mixed_params_client():
|
|
29
|
+
with MixedParamsClient("test-name-value") as client:
|
|
30
|
+
client.with_query(region="us-west", id="test-id")
|
|
31
|
+
client.with_body(Input(name="test-name"), region="us-west")
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def test_path_param_client():
|
|
35
|
+
with PathParamClient("sample-blob") as client:
|
|
36
|
+
client.with_query(format="text")
|
|
37
|
+
client.get_standalone()
|
|
38
|
+
client.delete_standalone()
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def test_param_alias_client():
|
|
42
|
+
with ParamAliasClient("sample-blob") as client:
|
|
43
|
+
client.with_aliased_name()
|
|
44
|
+
client.with_original_name()
|
|
@@ -4,8 +4,9 @@ azure-mgmt-core==1.5.0
|
|
|
4
4
|
|
|
5
5
|
# only for azure
|
|
6
6
|
-e ./generated/azure-client-generator-core-access
|
|
7
|
-
-e ./generated/azure-client-generator-core-
|
|
7
|
+
-e ./generated/azure-client-generator-core-client-initialization
|
|
8
8
|
-e ./generated/azure-client-generator-core-flatten-property
|
|
9
|
+
-e ./generated/azure-client-generator-core-usage
|
|
9
10
|
-e ./generated/azure-core-basic
|
|
10
11
|
-e ./generated/azure-core-scalar
|
|
11
12
|
-e ./generated/azure-core-lro-rpc
|
|
@@ -37,6 +38,7 @@ azure-mgmt-core==1.5.0
|
|
|
37
38
|
-e ./generated/encode-numeric
|
|
38
39
|
-e ./generated/parameters-basic
|
|
39
40
|
-e ./generated/parameters-collection-format
|
|
41
|
+
-e ./generated/parameters-path
|
|
40
42
|
-e ./generated/parameters-spread
|
|
41
43
|
-e ./generated/serialization-encoded-name-json
|
|
42
44
|
-e ./generated/server-endpoint-not-defined
|
|
@@ -0,0 +1,24 @@
|
|
|
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 parameters.path.aio import PathClient
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@pytest.fixture
|
|
11
|
+
async def client():
|
|
12
|
+
async with PathClient() as client:
|
|
13
|
+
yield client
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@pytest.mark.asyncio
|
|
17
|
+
async def test_normal(client: PathClient):
|
|
18
|
+
await client.normal("foo")
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@pytest.mark.asyncio
|
|
22
|
+
async def test_optional(client: PathClient):
|
|
23
|
+
await client.optional()
|
|
24
|
+
await client.optional(name="foo")
|
package/generator/test/generic_mock_api_tests/asynctests/test_typetest_property_nullable_async.py
CHANGED
|
@@ -8,7 +8,7 @@ import json
|
|
|
8
8
|
import pytest
|
|
9
9
|
from typetest.property.nullable import models
|
|
10
10
|
from typetest.property.nullable.aio import NullableClient
|
|
11
|
-
from typetest.property.nullable.
|
|
11
|
+
from typetest.property.nullable._utils.model_base import ( # pylint: disable=protected-access
|
|
12
12
|
SdkJSONEncoder,
|
|
13
13
|
)
|
|
14
14
|
|
|
@@ -0,0 +1,22 @@
|
|
|
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 parameters.path import PathClient
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@pytest.fixture
|
|
11
|
+
def client():
|
|
12
|
+
with PathClient() as client:
|
|
13
|
+
yield client
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def test_normal(client: PathClient):
|
|
17
|
+
client.normal("foo")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def test_optional(client: PathClient):
|
|
21
|
+
client.optional()
|
|
22
|
+
client.optional(name="foo")
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import json
|
|
8
8
|
import pytest
|
|
9
9
|
from typetest.property.nullable import NullableClient, models
|
|
10
|
-
from typetest.property.nullable.
|
|
10
|
+
from typetest.property.nullable._utils.model_base import ( # pylint: disable=protected-access
|
|
11
11
|
SdkJSONEncoder,
|
|
12
12
|
)
|
|
13
13
|
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
-e ./generated/encode-numeric
|
|
11
11
|
-e ./generated/parameters-basic
|
|
12
12
|
-e ./generated/parameters-collection-format
|
|
13
|
+
-e ./generated/parameters-path
|
|
13
14
|
-e ./generated/parameters-spread
|
|
14
15
|
-e ./generated/serialization-encoded-name-json
|
|
15
16
|
-e ./generated/server-endpoint-not-defined
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typespec/http-client-python",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"author": "Microsoft Corporation",
|
|
5
5
|
"description": "TypeSpec emitter for Python SDKs",
|
|
6
6
|
"homepage": "https://typespec.io",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"@azure-tools/typespec-azure-core": ">=0.54.0 <1.0.0",
|
|
59
59
|
"@azure-tools/typespec-azure-resource-manager": ">=0.54.0 <1.0.0",
|
|
60
60
|
"@azure-tools/typespec-azure-rulesets": ">=0.54.0 <1.0.0",
|
|
61
|
-
"@azure-tools/typespec-client-generator-core": ">=0.54.
|
|
61
|
+
"@azure-tools/typespec-client-generator-core": ">=0.54.2 <1.0.0",
|
|
62
62
|
"@typespec/compiler": "^1.0.0-0",
|
|
63
63
|
"@typespec/http": "^1.0.0-0",
|
|
64
64
|
"@typespec/openapi": "^1.0.0-0",
|
|
@@ -81,8 +81,8 @@
|
|
|
81
81
|
"@azure-tools/typespec-azure-core": "~0.54.0",
|
|
82
82
|
"@azure-tools/typespec-azure-resource-manager": "~0.54.0",
|
|
83
83
|
"@azure-tools/typespec-azure-rulesets": "~0.54.0",
|
|
84
|
-
"@azure-tools/typespec-client-generator-core": "~0.54.
|
|
85
|
-
"@azure-tools/azure-http-specs": "0.1.0-alpha.
|
|
84
|
+
"@azure-tools/typespec-client-generator-core": "~0.54.2",
|
|
85
|
+
"@azure-tools/azure-http-specs": "0.1.0-alpha.14",
|
|
86
86
|
"@typespec/compiler": "^1.0.0-0",
|
|
87
87
|
"@typespec/http": "^1.0.0-0",
|
|
88
88
|
"@typespec/openapi": "^1.0.0-0",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"@typespec/sse": "~0.68.0",
|
|
93
93
|
"@typespec/streams": "~0.68.0",
|
|
94
94
|
"@typespec/xml": "~0.68.0",
|
|
95
|
-
"@typespec/http-specs": "0.1.0-alpha.
|
|
95
|
+
"@typespec/http-specs": "0.1.0-alpha.19",
|
|
96
96
|
"@types/js-yaml": "~4.0.5",
|
|
97
97
|
"@types/node": "~22.13.14",
|
|
98
98
|
"@types/semver": "7.5.8",
|