set the entity to it's default value is present in the mapper and if the entity is not provided in the response.

This commit is contained in:
Amar Zavery 2019-07-10 15:07:41 -07:00
Родитель b530857066
Коммит efd965d0a0
3 изменённых файлов: 4 добавлений и 3 удалений

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

@ -416,7 +416,7 @@ function serializeDateTypes(typeName, value, objectName) {
*/
exports.deserialize = function (mapper, responseBody, objectName) {
if (responseBody === null || responseBody === undefined) {
if (mapper && mapper.isConstant) {
if (mapper && mapper.defaultValue) {
responseBody = mapper.defaultValue;
} else {
return responseBody;
@ -577,7 +577,7 @@ function deserializeCompositeType(mapper, responseBody, objectName) {
if (Array.isArray(responseBody[key]) && modelProps[key].serializedName === '') {
propertyInstance = responseBody[key];
instance = exports.deserialize.call(this, propertyMapper, propertyInstance, propertyObjectName);
} else if ((propertyInstance !== null && propertyInstance !== undefined) || (propertyMapper && propertyMapper.isConstant)) {
} else if ((propertyInstance !== null && propertyInstance !== undefined) || (propertyMapper && propertyMapper.defaultValue)) {
serializedValue = exports.deserialize.call(this, propertyMapper, propertyInstance, propertyObjectName);
instance[key] = serializedValue;
}

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

@ -55,4 +55,4 @@
"unit": "node test/unit.js testlist.txt",
"jshint": "jshint lib --reporter=jslint"
}
}
}

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

@ -1120,6 +1120,7 @@ describe('msrest', function () {
result.id.should.equal(5);
result.status.should.equal(true);
result.eyeColor.should.equal('brown');
result.favoriteFood.should.equal('bones');
result.odatalocation.should.equal('westus');
result.color.should.equal('red');
result.city.should.equal('Seattle');