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

This commit is contained in:
Amar Zavery 2019-07-30 19:15:46 -07:00
Родитель 401b56e557
Коммит 096687b544
5 изменённых файлов: 16 добавлений и 3 удалений

Просмотреть файл

@ -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.

Просмотреть файл

@ -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,

Просмотреть файл

@ -7,7 +7,7 @@ export const Constants = {
* @const
* @type {string}
*/
msRestVersion: "2.0.3",
msRestVersion: "2.0.4",
/**
* Specifies HTTP.

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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",