From 1c66198d94746df4413dd1e4f95b12cc8ec32917 Mon Sep 17 00:00:00 2001 From: iscai-msft <43154838+iscai-msft@users.noreply.github.com> Date: Fri, 31 May 2024 13:08:54 -0400 Subject: [PATCH] don't lowercase serialized body entries (#2608) --- .chronus/changes/fix_body_root-2024-4-31-12-40-38.md | 8 ++++++++ packages/autorest.python/autorest/preprocess/__init__.py | 6 +++--- .../payload/multipart/aio/operations/_operations.py | 2 +- .../payload/multipart/operations/_operations.py | 2 +- .../payload/multipart/aio/operations/_operations.py | 2 +- .../payload/multipart/operations/_operations.py | 2 +- 6 files changed, 15 insertions(+), 7 deletions(-) create mode 100644 .chronus/changes/fix_body_root-2024-4-31-12-40-38.md diff --git a/.chronus/changes/fix_body_root-2024-4-31-12-40-38.md b/.chronus/changes/fix_body_root-2024-4-31-12-40-38.md new file mode 100644 index 0000000000..fec8c3a451 --- /dev/null +++ b/.chronus/changes/fix_body_root-2024-4-31-12-40-38.md @@ -0,0 +1,8 @@ +--- +changeKind: fix +packages: + - "@autorest/python" + - "@azure-tools/typespec-python" +--- + +don't lowercase serialized names when building a body from splatted arguments \ No newline at end of file diff --git a/packages/autorest.python/autorest/preprocess/__init__.py b/packages/autorest.python/autorest/preprocess/__init__.py index 70c18c7f56..c9cf86e9ec 100644 --- a/packages/autorest.python/autorest/preprocess/__init__.py +++ b/packages/autorest.python/autorest/preprocess/__init__.py @@ -324,9 +324,9 @@ def update_parameter(self, yaml_data: Dict[str, Any]) -> None: if yaml_data.get("propertyToParameterName"): # need to create a new one with padded keys and values yaml_data["propertyToParameterName"] = { - self.pad_reserved_words(prop, PadType.PROPERTY) - .lower(): self.pad_reserved_words(param_name, PadType.PARAMETER) - .lower() + self.pad_reserved_words(prop, PadType.PROPERTY): self.pad_reserved_words( + param_name, PadType.PARAMETER + ).lower() for prop, param_name in yaml_data["propertyToParameterName"].items() } wire_name_lower = (yaml_data.get("wireName") or "").lower() diff --git a/packages/typespec-python/test/azure/generated/payload-multipart/payload/multipart/aio/operations/_operations.py b/packages/typespec-python/test/azure/generated/payload-multipart/payload/multipart/aio/operations/_operations.py index ebe54e6b43..b1ff0c1506 100644 --- a/packages/typespec-python/test/azure/generated/payload-multipart/payload/multipart/aio/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/payload-multipart/payload/multipart/aio/operations/_operations.py @@ -843,7 +843,7 @@ async def anonymous_model( # pylint: disable=inconsistent-return-statements if body is _Unset: if profile_image is _Unset: raise TypeError("missing required argument: profile_image") - body = {"profileimage": profile_image} + body = {"profileImage": profile_image} body = {k: v for k, v in body.items() if v is not None} _body = body.as_dict() if isinstance(body, _model_base.Model) else body _file_fields: List[str] = ["profileImage"] diff --git a/packages/typespec-python/test/azure/generated/payload-multipart/payload/multipart/operations/_operations.py b/packages/typespec-python/test/azure/generated/payload-multipart/payload/multipart/operations/_operations.py index f2d0406b16..2077c9f2d3 100644 --- a/packages/typespec-python/test/azure/generated/payload-multipart/payload/multipart/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/payload-multipart/payload/multipart/operations/_operations.py @@ -904,7 +904,7 @@ def anonymous_model( # pylint: disable=inconsistent-return-statements if body is _Unset: if profile_image is _Unset: raise TypeError("missing required argument: profile_image") - body = {"profileimage": profile_image} + body = {"profileImage": profile_image} body = {k: v for k, v in body.items() if v is not None} _body = body.as_dict() if isinstance(body, _model_base.Model) else body _file_fields: List[str] = ["profileImage"] diff --git a/packages/typespec-python/test/unbranded/generated/payload-multipart/payload/multipart/aio/operations/_operations.py b/packages/typespec-python/test/unbranded/generated/payload-multipart/payload/multipart/aio/operations/_operations.py index dfa40939b6..4d78d10507 100644 --- a/packages/typespec-python/test/unbranded/generated/payload-multipart/payload/multipart/aio/operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/payload-multipart/payload/multipart/aio/operations/_operations.py @@ -834,7 +834,7 @@ async def anonymous_model( # pylint: disable=inconsistent-return-statements if body is _Unset: if profile_image is _Unset: raise TypeError("missing required argument: profile_image") - body = {"profileimage": profile_image} + body = {"profileImage": profile_image} body = {k: v for k, v in body.items() if v is not None} _body = body.as_dict() if isinstance(body, _model_base.Model) else body _file_fields: List[str] = ["profileImage"] diff --git a/packages/typespec-python/test/unbranded/generated/payload-multipart/payload/multipart/operations/_operations.py b/packages/typespec-python/test/unbranded/generated/payload-multipart/payload/multipart/operations/_operations.py index 2699fc916a..1b34506d23 100644 --- a/packages/typespec-python/test/unbranded/generated/payload-multipart/payload/multipart/operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/payload-multipart/payload/multipart/operations/_operations.py @@ -895,7 +895,7 @@ def anonymous_model( # pylint: disable=inconsistent-return-statements if body is _Unset: if profile_image is _Unset: raise TypeError("missing required argument: profile_image") - body = {"profileimage": profile_image} + body = {"profileImage": profile_image} body = {k: v for k, v in body.items() if v is not None} _body = body.as_dict() if isinstance(body, _model_base.Model) else body _file_fields: List[str] = ["profileImage"]