Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
changeKind: fix
packages:
- "@autorest/python"
- "@azure-tools/typespec-python"
---

Add overload for operation when body type is array of model
2 changes: 1 addition & 1 deletion packages/autorest.python/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"homepage": "https://github.com/Azure/autorest.python/blob/main/README.md",
"dependencies": {
"@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNTM2NTY3Ni9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.17.0.tgz",
"@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNTM3MDU0Ny9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.17.0.tgz",
"@autorest/system-requirements": "~1.0.2",
"fs-extra": "~11.2.0",
"tsx": "~4.19.1"
Expand Down
2 changes: 1 addition & 1 deletion packages/typespec-python/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"js-yaml": "~4.1.0",
"semver": "~7.6.2",
"tsx": "~4.19.1",
"@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNTM2NTY3Ni9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.17.0.tgz",
"@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNTM3MDU0Ny9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.17.0.tgz",
"fs-extra": "~11.2.0"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@

T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]]
JSON = MutableMapping[str, Any]


class Int32ValueOperations:
Expand Down Expand Up @@ -1424,6 +1425,20 @@ async def put(
:raises ~azure.core.exceptions.HttpResponseError:
"""

@overload
async def put(self, body: list[JSON], *, content_type: str = "application/json", **kwargs: Any) -> None:
"""put.

:param body: Required.
:type body: list[JSON]
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:return: None
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""

@overload
async def put(self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any) -> None:
"""put.
Expand All @@ -1439,11 +1454,11 @@ async def put(self, body: IO[bytes], *, content_type: str = "application/json",
"""

@distributed_trace_async
async def put(self, body: Union[list[_models.InnerModel], IO[bytes]], **kwargs: Any) -> None:
async def put(self, body: Union[list[_models.InnerModel], list[JSON], IO[bytes]], **kwargs: Any) -> None:
"""put.

:param body: Is either a [InnerModel] type or a IO[bytes] type. Required.
:type body: list[~typetest.array.models.InnerModel] or IO[bytes]
:param body: Is one of the following types: [InnerModel], [JSON], IO[bytes] Required.
:type body: list[~typetest.array.models.InnerModel] or list[JSON] or IO[bytes]
:return: None
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
Expand Down Expand Up @@ -2216,6 +2231,20 @@ async def put(
:raises ~azure.core.exceptions.HttpResponseError:
"""

@overload
async def put(self, body: list[JSON], *, content_type: str = "application/json", **kwargs: Any) -> None:
"""put.

:param body: Required.
:type body: list[JSON]
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:return: None
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""

@overload
async def put(self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any) -> None:
"""put.
Expand All @@ -2231,11 +2260,11 @@ async def put(self, body: IO[bytes], *, content_type: str = "application/json",
"""

@distributed_trace_async
async def put(self, body: Union[list[_models.InnerModel], IO[bytes]], **kwargs: Any) -> None:
async def put(self, body: Union[list[_models.InnerModel], list[JSON], IO[bytes]], **kwargs: Any) -> None:
"""put.

:param body: Is either a [InnerModel] type or a IO[bytes] type. Required.
:type body: list[~typetest.array.models.InnerModel] or IO[bytes]
:param body: Is one of the following types: [InnerModel], [JSON], IO[bytes] Required.
:type body: list[~typetest.array.models.InnerModel] or list[JSON] or IO[bytes]
:return: None
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]]
JSON = MutableMapping[str, Any]

_SERIALIZER = Serializer()
_SERIALIZER.client_side_validation = False
Expand Down Expand Up @@ -1799,6 +1800,20 @@ def put(self, body: list[_models.InnerModel], *, content_type: str = "applicatio
:raises ~azure.core.exceptions.HttpResponseError:
"""

@overload
def put(self, body: list[JSON], *, content_type: str = "application/json", **kwargs: Any) -> None:
"""put.

:param body: Required.
:type body: list[JSON]
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:return: None
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""

@overload
def put(self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any) -> None:
"""put.
Expand All @@ -1815,12 +1830,12 @@ def put(self, body: IO[bytes], *, content_type: str = "application/json", **kwar

@distributed_trace
def put( # pylint: disable=inconsistent-return-statements
self, body: Union[list[_models.InnerModel], IO[bytes]], **kwargs: Any
self, body: Union[list[_models.InnerModel], list[JSON], IO[bytes]], **kwargs: Any
) -> None:
"""put.

:param body: Is either a [InnerModel] type or a IO[bytes] type. Required.
:type body: list[~typetest.array.models.InnerModel] or IO[bytes]
:param body: Is one of the following types: [InnerModel], [JSON], IO[bytes] Required.
:type body: list[~typetest.array.models.InnerModel] or list[JSON] or IO[bytes]
:return: None
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
Expand Down Expand Up @@ -2599,6 +2614,20 @@ def put(self, body: list[_models.InnerModel], *, content_type: str = "applicatio
:raises ~azure.core.exceptions.HttpResponseError:
"""

@overload
def put(self, body: list[JSON], *, content_type: str = "application/json", **kwargs: Any) -> None:
"""put.

:param body: Required.
:type body: list[JSON]
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:return: None
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""

@overload
def put(self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any) -> None:
"""put.
Expand All @@ -2615,12 +2644,12 @@ def put(self, body: IO[bytes], *, content_type: str = "application/json", **kwar

@distributed_trace
def put( # pylint: disable=inconsistent-return-statements
self, body: Union[list[_models.InnerModel], IO[bytes]], **kwargs: Any
self, body: Union[list[_models.InnerModel], list[JSON], IO[bytes]], **kwargs: Any
) -> None:
"""put.

:param body: Is either a [InnerModel] type or a IO[bytes] type. Required.
:type body: list[~typetest.array.models.InnerModel] or IO[bytes]
:param body: Is one of the following types: [InnerModel], [JSON], IO[bytes] Required.
:type body: list[~typetest.array.models.InnerModel] or list[JSON] or IO[bytes]
:return: None
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@

T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]]
JSON = MutableMapping[str, Any]


class Int32ValueOperations:
Expand Down Expand Up @@ -1418,6 +1419,20 @@ async def put(
:raises ~azure.core.exceptions.HttpResponseError:
"""

@overload
async def put(self, body: dict[str, JSON], *, content_type: str = "application/json", **kwargs: Any) -> None:
"""put.

:param body: Required.
:type body: dict[str, JSON]
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:return: None
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""

@overload
async def put(self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any) -> None:
"""put.
Expand All @@ -1433,11 +1448,11 @@ async def put(self, body: IO[bytes], *, content_type: str = "application/json",
"""

@distributed_trace_async
async def put(self, body: Union[dict[str, _models.InnerModel], IO[bytes]], **kwargs: Any) -> None:
async def put(self, body: Union[dict[str, _models.InnerModel], dict[str, JSON], IO[bytes]], **kwargs: Any) -> None:
"""put.

:param body: Is either a {str: InnerModel} type or a IO[bytes] type. Required.
:type body: dict[str, ~typetest.dictionary.models.InnerModel] or IO[bytes]
:param body: Is one of the following types: {str: InnerModel}, {str: JSON}, IO[bytes] Required.
:type body: dict[str, ~typetest.dictionary.models.InnerModel] or dict[str, JSON] or IO[bytes]
:return: None
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
Expand Down Expand Up @@ -1578,6 +1593,20 @@ async def put(
:raises ~azure.core.exceptions.HttpResponseError:
"""

@overload
async def put(self, body: dict[str, JSON], *, content_type: str = "application/json", **kwargs: Any) -> None:
"""put.

:param body: Required.
:type body: dict[str, JSON]
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:return: None
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""

@overload
async def put(self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any) -> None:
"""put.
Expand All @@ -1593,11 +1622,11 @@ async def put(self, body: IO[bytes], *, content_type: str = "application/json",
"""

@distributed_trace_async
async def put(self, body: Union[dict[str, _models.InnerModel], IO[bytes]], **kwargs: Any) -> None:
async def put(self, body: Union[dict[str, _models.InnerModel], dict[str, JSON], IO[bytes]], **kwargs: Any) -> None:
"""put.

:param body: Is either a {str: InnerModel} type or a IO[bytes] type. Required.
:type body: dict[str, ~typetest.dictionary.models.InnerModel] or IO[bytes]
:param body: Is one of the following types: {str: InnerModel}, {str: JSON}, IO[bytes] Required.
:type body: dict[str, ~typetest.dictionary.models.InnerModel] or dict[str, JSON] or IO[bytes]
:return: None
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

T = TypeVar("T")
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]]
JSON = MutableMapping[str, Any]

_SERIALIZER = Serializer()
_SERIALIZER.client_side_validation = False
Expand Down Expand Up @@ -1719,6 +1720,20 @@ def put(
:raises ~azure.core.exceptions.HttpResponseError:
"""

@overload
def put(self, body: dict[str, JSON], *, content_type: str = "application/json", **kwargs: Any) -> None:
"""put.

:param body: Required.
:type body: dict[str, JSON]
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:return: None
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""

@overload
def put(self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any) -> None:
"""put.
Expand All @@ -1735,12 +1750,12 @@ def put(self, body: IO[bytes], *, content_type: str = "application/json", **kwar

@distributed_trace
def put( # pylint: disable=inconsistent-return-statements
self, body: Union[dict[str, _models.InnerModel], IO[bytes]], **kwargs: Any
self, body: Union[dict[str, _models.InnerModel], dict[str, JSON], IO[bytes]], **kwargs: Any
) -> None:
"""put.

:param body: Is either a {str: InnerModel} type or a IO[bytes] type. Required.
:type body: dict[str, ~typetest.dictionary.models.InnerModel] or IO[bytes]
:param body: Is one of the following types: {str: InnerModel}, {str: JSON}, IO[bytes] Required.
:type body: dict[str, ~typetest.dictionary.models.InnerModel] or dict[str, JSON] or IO[bytes]
:return: None
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
Expand Down Expand Up @@ -1881,6 +1896,20 @@ def put(
:raises ~azure.core.exceptions.HttpResponseError:
"""

@overload
def put(self, body: dict[str, JSON], *, content_type: str = "application/json", **kwargs: Any) -> None:
"""put.

:param body: Required.
:type body: dict[str, JSON]
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:return: None
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""

@overload
def put(self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any) -> None:
"""put.
Expand All @@ -1897,12 +1926,12 @@ def put(self, body: IO[bytes], *, content_type: str = "application/json", **kwar

@distributed_trace
def put( # pylint: disable=inconsistent-return-statements
self, body: Union[dict[str, _models.InnerModel], IO[bytes]], **kwargs: Any
self, body: Union[dict[str, _models.InnerModel], dict[str, JSON], IO[bytes]], **kwargs: Any
) -> None:
"""put.

:param body: Is either a {str: InnerModel} type or a IO[bytes] type. Required.
:type body: dict[str, ~typetest.dictionary.models.InnerModel] or IO[bytes]
:param body: Is one of the following types: {str: InnerModel}, {str: JSON}, IO[bytes] Required.
:type body: dict[str, ~typetest.dictionary.models.InnerModel] or dict[str, JSON] or IO[bytes]
:return: None
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,22 @@ async def test_model_value(client: ArrayClient):
models.InnerModel(property="hello"),
models.InnerModel(property="world"),
]
# test list[model]
await client.model_value.put(
[
models.InnerModel(property="hello"),
models.InnerModel(property="world"),
]
)

# test list[JSON]
await client.model_value.put(
[
{"property": "hello"},
{"property": "world"},
]
)


@pytest.mark.asyncio
async def test_nullable_boolean_value(client: ArrayClient):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,20 @@ def test_model_value(client: ArrayClient):
models.InnerModel(property="hello"),
models.InnerModel(property="world"),
]
# test list[model]
client.model_value.put(
[
models.InnerModel(property="hello"),
models.InnerModel(property="world"),
]
)
# test list[JSON]
client.model_value.put(
[
{"property": "hello"},
{"property": "world"},
]
)


def test_nullable_boolean_value(client: ArrayClient):
Expand Down
Loading
Loading