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 00000000000..fec8c3a4516 --- /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 70c18c7f566..c9cf86e9ec3 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 ebe54e6b439..b1ff0c1506a 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 f2d0406b16a..2077c9f2d3f 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 dfa40939b62..4d78d105071 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 2699fc916a3..1b34506d237 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"]