Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that a primitive type (string, number, boolean, null, undefined) response body with or without a bodyMapper is not flattened #369

Merged
merged 1 commit into from
Jul 31, 2019
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
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Changelog
## 2.0.4 - 2019-07-30
- Ensure that a primitive type (string, number, boolean, null, undefined) response body with or without a `bodyMapper` is not flattened.

## 2.0.3 - 2019-07-11
- Added support to not send default values while sending the request.
- Added support to populate entities with it's default value if it is present in the mapper while deserializing the response.
Expand Down
2 changes: 1 addition & 1 deletion lib/serviceClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ export function flattenResponse(_response: HttpOperationResponse, responseSpec:
}
}

if (bodyMapper || _response.request.method === "HEAD") {
if (bodyMapper || _response.request.method === "HEAD" || utils.isPrimitiveType(_response.parsedBody)) {
// primitive body types and HEAD booleans
return addOperationResponse({
...parsedHeaders,
Expand Down
2 changes: 1 addition & 1 deletion lib/util/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const Constants = {
* @const
* @type {string}
*/
msRestVersion: "2.0.3",
msRestVersion: "2.0.4",

/**
* Specifies HTTP.
Expand Down
10 changes: 10 additions & 0 deletions lib/util/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,13 @@ export function isDuration(value: string): boolean {
export function replaceAll(value: string | undefined, searchValue: string, replaceValue: string): string | undefined {
return !value || !searchValue ? value : value.split(searchValue).join(replaceValue || "");
}

/**
* Determines whether the given enity is a basic/primitive type
* (string, number, boolean, null, undefined).
* @param value Any entity
* @return boolean - true is it is primitive type, false otherwise.
*/
export function isPrimitiveType(value: any): boolean {
return (typeof value !== "object" && typeof value !== "function") || value === null;
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"email": "azsdkteam@microsoft.com",
"url": "https://github.com/Azure/ms-rest-js"
},
"version": "2.0.3",
"version": "2.0.4",
"description": "Isomorphic client Runtime for Typescript/node.js/browser javascript client libraries generated using AutoRest",
"tags": [
"isomorphic",
Expand Down