Skip to content

Commit 7eab864

Browse files
authored
[core-rest-pipeline] Fix serialization of body of false (Azure#14218)
If the body contains just false, this check will confuse it with the body being non existent. This PR fixes this issue.
1 parent f858ce0 commit 7eab864

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

sdk/core/core-client/src/serializationPolicy.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,17 @@ export function serializeRequestBody(
127127
xmlName,
128128
xmlElementName,
129129
xmlNamespace,
130-
xmlNamespacePrefix
130+
xmlNamespacePrefix,
131+
nullable
131132
} = bodyMapper;
132133
const typeName = bodyMapper.type.name;
133134

134135
try {
135-
if (request.body || required) {
136+
if (
137+
(request.body !== undefined && request.body !== null) ||
138+
(nullable && request.body === null) ||
139+
required
140+
) {
136141
const requestBodyParameterPathString: string = getPathStringFromParameter(
137142
operationSpec.requestBody
138143
);

0 commit comments

Comments
 (0)