diff --git a/.chronus/changes/upgrade_spector-2025-7-19-11-51-56.md b/.chronus/changes/upgrade_spector-2025-7-19-11-51-56.md new file mode 100644 index 00000000000..c8eba523aa0 --- /dev/null +++ b/.chronus/changes/upgrade_spector-2025-7-19-11-51-56.md @@ -0,0 +1,7 @@ +--- +changeKind: dependencies +packages: + - "@azure-tools/typespec-python" +--- + +Upgrade azure-http-specs version. \ No newline at end of file diff --git a/packages/typespec-python/package.json b/packages/typespec-python/package.json index 1875d563dad..271ba250a04 100644 --- a/packages/typespec-python/package.json +++ b/packages/typespec-python/package.json @@ -86,7 +86,7 @@ "@azure-tools/typespec-azure-rulesets": "~0.59.0", "@azure-tools/typespec-autorest": "~0.59.0", "@azure-tools/typespec-client-generator-core": "~0.59.0", - "@azure-tools/azure-http-specs": "0.1.0-alpha.25", + "@azure-tools/azure-http-specs": "0.1.0-alpha.27", "@typespec/http-specs": "0.1.0-alpha.25", "@typespec/spector": "0.1.0-alpha.17", "@typespec/spec-api": "0.1.0-alpha.8", @@ -103,4 +103,4 @@ "chalk": "5.3.0", "@types/fs-extra": "11.0.4" } -} \ No newline at end of file +} diff --git a/packages/typespec-python/test/azure/generated/client-naming/apiview-properties.json b/packages/typespec-python/test/azure/generated/client-naming/apiview-properties.json index d8cf2e521bf..c036da9bbf4 100644 --- a/packages/typespec-python/test/azure/generated/client-naming/apiview-properties.json +++ b/packages/typespec-python/test/azure/generated/client-naming/apiview-properties.json @@ -8,10 +8,10 @@ "client.naming.models.PythonModel": "Client.Naming.Model.ModelWithLanguageClientName", "client.naming.models.ClientExtensibleEnum": "Client.Naming.UnionEnum.ServerExtensibleEnum", "client.naming.models.ExtensibleEnum": "Client.Naming.UnionEnum.ExtensibleEnum", - "client.naming.operations.ClientModelOperations.client": "Client.Naming.Model.client", - "client.naming.aio.operations.ClientModelOperations.client": "Client.Naming.Model.client", - "client.naming.operations.ClientModelOperations.language": "Client.Naming.Model.language", - "client.naming.aio.operations.ClientModelOperations.language": "Client.Naming.Model.language", + "client.naming.operations.ModelClientOperations.client": "Client.Naming.Model.client", + "client.naming.aio.operations.ModelClientOperations.client": "Client.Naming.Model.client", + "client.naming.operations.ModelClientOperations.language": "Client.Naming.Model.language", + "client.naming.aio.operations.ModelClientOperations.language": "Client.Naming.Model.language", "client.naming.operations.UnionEnumOperations.union_enum_name": "Client.Naming.UnionEnum.unionEnumName", "client.naming.aio.operations.UnionEnumOperations.union_enum_name": "Client.Naming.UnionEnum.unionEnumName", "client.naming.operations.UnionEnumOperations.union_enum_member_name": "Client.Naming.UnionEnum.unionEnumMemberName", diff --git a/packages/typespec-python/test/azure/generated/client-naming/client/naming/_client.py b/packages/typespec-python/test/azure/generated/client-naming/client/naming/_client.py index b7eef00bc32..f654b9adbb6 100644 --- a/packages/typespec-python/test/azure/generated/client-naming/client/naming/_client.py +++ b/packages/typespec-python/test/azure/generated/client-naming/client/naming/_client.py @@ -16,14 +16,14 @@ from ._configuration import NamingClientConfiguration from ._utils.serialization import Deserializer, Serializer -from .operations import ClientModelOperations, UnionEnumOperations, _NamingClientOperationsMixin +from .operations import ModelClientOperations, UnionEnumOperations, _NamingClientOperationsMixin class NamingClient(_NamingClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword """Describe changing names of types in a client with ``@clientName``. - :ivar client_model: ClientModelOperations operations - :vartype client_model: client.naming.operations.ClientModelOperations + :ivar model_client: ModelClientOperations operations + :vartype model_client: client.naming.operations.ModelClientOperations :ivar union_enum: UnionEnumOperations operations :vartype union_enum: client.naming.operations.UnionEnumOperations :keyword endpoint: Service host. Default value is "http://localhost:3000". @@ -58,7 +58,7 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential self._serialize = Serializer() self._deserialize = Deserializer() self._serialize.client_side_validation = False - self.client_model = ClientModelOperations(self._client, self._config, self._serialize, self._deserialize) + self.model_client = ModelClientOperations(self._client, self._config, self._serialize, self._deserialize) self.union_enum = UnionEnumOperations(self._client, self._config, self._serialize, self._deserialize) def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: diff --git a/packages/typespec-python/test/azure/generated/client-naming/client/naming/aio/_client.py b/packages/typespec-python/test/azure/generated/client-naming/client/naming/aio/_client.py index 84e825c8725..a7499bbf986 100644 --- a/packages/typespec-python/test/azure/generated/client-naming/client/naming/aio/_client.py +++ b/packages/typespec-python/test/azure/generated/client-naming/client/naming/aio/_client.py @@ -16,14 +16,14 @@ from .._utils.serialization import Deserializer, Serializer from ._configuration import NamingClientConfiguration -from .operations import ClientModelOperations, UnionEnumOperations, _NamingClientOperationsMixin +from .operations import ModelClientOperations, UnionEnumOperations, _NamingClientOperationsMixin class NamingClient(_NamingClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword """Describe changing names of types in a client with ``@clientName``. - :ivar client_model: ClientModelOperations operations - :vartype client_model: client.naming.aio.operations.ClientModelOperations + :ivar model_client: ModelClientOperations operations + :vartype model_client: client.naming.aio.operations.ModelClientOperations :ivar union_enum: UnionEnumOperations operations :vartype union_enum: client.naming.aio.operations.UnionEnumOperations :keyword endpoint: Service host. Default value is "http://localhost:3000". @@ -58,7 +58,7 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential self._serialize = Serializer() self._deserialize = Deserializer() self._serialize.client_side_validation = False - self.client_model = ClientModelOperations(self._client, self._config, self._serialize, self._deserialize) + self.model_client = ModelClientOperations(self._client, self._config, self._serialize, self._deserialize) self.union_enum = UnionEnumOperations(self._client, self._config, self._serialize, self._deserialize) def send_request( diff --git a/packages/typespec-python/test/azure/generated/client-naming/client/naming/aio/operations/__init__.py b/packages/typespec-python/test/azure/generated/client-naming/client/naming/aio/operations/__init__.py index 60dbba1776e..6ca21ae8c9e 100644 --- a/packages/typespec-python/test/azure/generated/client-naming/client/naming/aio/operations/__init__.py +++ b/packages/typespec-python/test/azure/generated/client-naming/client/naming/aio/operations/__init__.py @@ -12,7 +12,7 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._operations import ClientModelOperations # type: ignore +from ._operations import ModelClientOperations # type: ignore from ._operations import UnionEnumOperations # type: ignore from ._operations import _NamingClientOperationsMixin # type: ignore # pylint: disable=unused-import @@ -21,7 +21,7 @@ from ._patch import patch_sdk as _patch_sdk __all__ = [ - "ClientModelOperations", + "ModelClientOperations", "UnionEnumOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore diff --git a/packages/typespec-python/test/azure/generated/client-naming/client/naming/aio/operations/_operations.py b/packages/typespec-python/test/azure/generated/client-naming/client/naming/aio/operations/_operations.py index c504e7294cf..012320e68bd 100644 --- a/packages/typespec-python/test/azure/generated/client-naming/client/naming/aio/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/client-naming/client/naming/aio/operations/_operations.py @@ -30,8 +30,8 @@ from ..._utils.serialization import Deserializer, Serializer from ..._utils.utils import ClientMixinABC from ...operations._operations import ( - build_client_model_client_request, - build_client_model_language_request, + build_model_client_client_request, + build_model_client_language_request, build_naming_client_name_request, build_naming_client_request, build_naming_compatible_with_encoded_name_request, @@ -49,14 +49,14 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ClientModelOperations: +class ModelClientOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~client.naming.aio.NamingClient`'s - :attr:`client_model` attribute. + :attr:`model_client` attribute. """ def __init__(self, *args, **kwargs) -> None: @@ -139,7 +139,7 @@ async def client(self, body: Union[_models.ClientModel, JSON, IO[bytes]], **kwar else: _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_client_model_client_request( + _request = build_model_client_client_request( content_type=content_type, content=_content, headers=_headers, @@ -239,7 +239,7 @@ async def language(self, body: Union[_models.PythonModel, JSON, IO[bytes]], **kw else: _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_client_model_language_request( + _request = build_model_client_language_request( content_type=content_type, content=_content, headers=_headers, diff --git a/packages/typespec-python/test/azure/generated/client-naming/client/naming/operations/__init__.py b/packages/typespec-python/test/azure/generated/client-naming/client/naming/operations/__init__.py index 60dbba1776e..6ca21ae8c9e 100644 --- a/packages/typespec-python/test/azure/generated/client-naming/client/naming/operations/__init__.py +++ b/packages/typespec-python/test/azure/generated/client-naming/client/naming/operations/__init__.py @@ -12,7 +12,7 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._operations import ClientModelOperations # type: ignore +from ._operations import ModelClientOperations # type: ignore from ._operations import UnionEnumOperations # type: ignore from ._operations import _NamingClientOperationsMixin # type: ignore # pylint: disable=unused-import @@ -21,7 +21,7 @@ from ._patch import patch_sdk as _patch_sdk __all__ = [ - "ClientModelOperations", + "ModelClientOperations", "UnionEnumOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore diff --git a/packages/typespec-python/test/azure/generated/client-naming/client/naming/operations/_operations.py b/packages/typespec-python/test/azure/generated/client-naming/client/naming/operations/_operations.py index eb41fd88a56..8c0330b613f 100644 --- a/packages/typespec-python/test/azure/generated/client-naming/client/naming/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/client-naming/client/naming/operations/_operations.py @@ -39,7 +39,7 @@ _SERIALIZER.client_side_validation = False -def build_client_model_client_request(**kwargs: Any) -> HttpRequest: +def build_model_client_client_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) @@ -53,7 +53,7 @@ def build_client_model_client_request(**kwargs: Any) -> HttpRequest: return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) -def build_client_model_language_request(**kwargs: Any) -> HttpRequest: +def build_model_client_language_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) @@ -173,14 +173,14 @@ def build_naming_response_request(**kwargs: Any) -> HttpRequest: return HttpRequest(method="GET", url=_url, **kwargs) -class ClientModelOperations: +class ModelClientOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~client.naming.NamingClient`'s - :attr:`client_model` attribute. + :attr:`model_client` attribute. """ def __init__(self, *args, **kwargs) -> None: @@ -265,7 +265,7 @@ def client( # pylint: disable=inconsistent-return-statements else: _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_client_model_client_request( + _request = build_model_client_client_request( content_type=content_type, content=_content, headers=_headers, @@ -365,7 +365,7 @@ def language( # pylint: disable=inconsistent-return-statements else: _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_client_model_language_request( + _request = build_model_client_language_request( content_type=content_type, content=_content, headers=_headers, diff --git a/packages/typespec-python/test/azure/generated/client-naming/generated_tests/test_naming_model_client_operations.py b/packages/typespec-python/test/azure/generated/client-naming/generated_tests/test_naming_model_client_operations.py new file mode 100644 index 00000000000..d568b026d1c --- /dev/null +++ b/packages/typespec-python/test/azure/generated/client-naming/generated_tests/test_naming_model_client_operations.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from devtools_testutils import recorded_by_proxy +from testpreparer import NamingClientTestBase, NamingPreparer + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestNamingModelClientOperations(NamingClientTestBase): + @NamingPreparer() + @recorded_by_proxy + def test_model_client_client(self, naming_endpoint): + client = self.create_client(endpoint=naming_endpoint) + response = client.model_client.client( + body={"defaultName": bool}, + ) + + # please add some check logic here by yourself + # ... + + @NamingPreparer() + @recorded_by_proxy + def test_model_client_language(self, naming_endpoint): + client = self.create_client(endpoint=naming_endpoint) + response = client.model_client.language( + body={"defaultName": bool}, + ) + + # please add some check logic here by yourself + # ... diff --git a/packages/typespec-python/test/azure/generated/client-naming/generated_tests/test_naming_model_client_operations_async.py b/packages/typespec-python/test/azure/generated/client-naming/generated_tests/test_naming_model_client_operations_async.py new file mode 100644 index 00000000000..22986078e5f --- /dev/null +++ b/packages/typespec-python/test/azure/generated/client-naming/generated_tests/test_naming_model_client_operations_async.py @@ -0,0 +1,36 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from devtools_testutils.aio import recorded_by_proxy_async +from testpreparer import NamingPreparer +from testpreparer_async import NamingClientTestBaseAsync + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestNamingModelClientOperationsAsync(NamingClientTestBaseAsync): + @NamingPreparer() + @recorded_by_proxy_async + async def test_model_client_client(self, naming_endpoint): + client = self.create_async_client(endpoint=naming_endpoint) + response = await client.model_client.client( + body={"defaultName": bool}, + ) + + # please add some check logic here by yourself + # ... + + @NamingPreparer() + @recorded_by_proxy_async + async def test_model_client_language(self, naming_endpoint): + client = self.create_async_client(endpoint=naming_endpoint) + response = await client.model_client.language( + body={"defaultName": bool}, + ) + + # please add some check logic here by yourself + # ... diff --git a/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_client_naming_async.py b/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_client_naming_async.py index 3d6ff696996..fcbb859330e 100644 --- a/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_client_naming_async.py +++ b/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_client_naming_async.py @@ -51,12 +51,12 @@ async def test_header_response(client: NamingClient): @pytest.mark.asyncio async def test_model_client(client: NamingClient): - await client.client_model.client(models.ClientModel(default_name=True)) + await client.model_client.client(models.ClientModel(default_name=True)) @pytest.mark.asyncio async def test_model_language(client: NamingClient): - await client.client_model.language(models.PythonModel(default_name=True)) + await client.model_client.language(models.PythonModel(default_name=True)) @pytest.mark.asyncio diff --git a/packages/typespec-python/test/azure/mock_api_tests/test_client_naming.py b/packages/typespec-python/test/azure/mock_api_tests/test_client_naming.py index 023c2f3aa87..0ffdb4726e3 100644 --- a/packages/typespec-python/test/azure/mock_api_tests/test_client_naming.py +++ b/packages/typespec-python/test/azure/mock_api_tests/test_client_naming.py @@ -42,11 +42,11 @@ def test_header_response(client: NamingClient): def test_model_client(client: NamingClient): - client.client_model.client(models.ClientModel(default_name=True)) + client.model_client.client(models.ClientModel(default_name=True)) def test_model_language(client: NamingClient): - client.client_model.language(models.PythonModel(default_name=True)) + client.model_client.language(models.PythonModel(default_name=True)) def test_union_enum_member_name(client: NamingClient): diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c4a0f0e8afe..b4f6fcd429c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -98,8 +98,8 @@ importers: version: 4.19.3 devDependencies: '@azure-tools/azure-http-specs': - specifier: 0.1.0-alpha.25 - version: 0.1.0-alpha.25(tsnbxk7z3h65bhkmgjy2jtqk7m) + specifier: 0.1.0-alpha.27 + version: 0.1.0-alpha.27(tsnbxk7z3h65bhkmgjy2jtqk7m) '@azure-tools/typespec-autorest': specifier: ~0.59.0 version: 0.59.0(tlfj6gbglsbr5x2lirzpm33h7y) @@ -209,8 +209,8 @@ packages: resolution: {integrity: sha512-T21naRb6JDdjjn2s/zwr9iCIv/9jviL/PRtiWAhi+3UA2WKH2wrId2VqJa4uVD7iEV8BLkuGgFmMkaMBG26hFw==} engines: {node: '>=12.0.0'} - '@azure-tools/azure-http-specs@0.1.0-alpha.25': - resolution: {integrity: sha512-fvexvGbDUUcd6su+RCln/hrOosbWYvl1FaycaifX0NVJub/ne492G2dvHLgp2N8rnUJ9uIenXYjHZHYsrjyGHQ==} + '@azure-tools/azure-http-specs@0.1.0-alpha.27': + resolution: {integrity: sha512-70+PKuUGz/Uw7M5bS8daIf8OGw2nvZy9j4OC0Sy2dcEy8I85JgysE9Cjv59f9qsUFyVsGydI/uQSv4Njvnjfcg==} engines: {node: '>=20.0.0'} peerDependencies: '@azure-tools/typespec-azure-core': ^0.59.0 @@ -4866,7 +4866,7 @@ snapshots: command-exists: 1.2.9 semver: 7.6.3 - '@azure-tools/azure-http-specs@0.1.0-alpha.25(tsnbxk7z3h65bhkmgjy2jtqk7m)': + '@azure-tools/azure-http-specs@0.1.0-alpha.27(tsnbxk7z3h65bhkmgjy2jtqk7m)': dependencies: '@azure-tools/typespec-azure-core': 0.59.0(@typespec/compiler@1.3.0(@types/node@24.1.0))(@typespec/http@1.3.0(@typespec/compiler@1.3.0(@types/node@24.1.0))(@typespec/streams@0.73.0(@typespec/compiler@1.3.0(@types/node@24.1.0))))(@typespec/rest@0.73.0(@typespec/compiler@1.3.0(@types/node@24.1.0))(@typespec/http@1.3.0(@typespec/compiler@1.3.0(@types/node@24.1.0))(@typespec/streams@0.73.0(@typespec/compiler@1.3.0(@types/node@24.1.0))))) '@typespec/compiler': 1.3.0(@types/node@24.1.0)