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:
Родитель
b530857066
Коммит
efd965d0a0
|
@ -416,7 +416,7 @@ function serializeDateTypes(typeName, value, objectName) {
|
||||||
*/
|
*/
|
||||||
exports.deserialize = function (mapper, responseBody, objectName) {
|
exports.deserialize = function (mapper, responseBody, objectName) {
|
||||||
if (responseBody === null || responseBody === undefined) {
|
if (responseBody === null || responseBody === undefined) {
|
||||||
if (mapper && mapper.isConstant) {
|
if (mapper && mapper.defaultValue) {
|
||||||
responseBody = mapper.defaultValue;
|
responseBody = mapper.defaultValue;
|
||||||
} else {
|
} else {
|
||||||
return responseBody;
|
return responseBody;
|
||||||
|
@ -577,7 +577,7 @@ function deserializeCompositeType(mapper, responseBody, objectName) {
|
||||||
if (Array.isArray(responseBody[key]) && modelProps[key].serializedName === '') {
|
if (Array.isArray(responseBody[key]) && modelProps[key].serializedName === '') {
|
||||||
propertyInstance = responseBody[key];
|
propertyInstance = responseBody[key];
|
||||||
instance = exports.deserialize.call(this, propertyMapper, propertyInstance, propertyObjectName);
|
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);
|
serializedValue = exports.deserialize.call(this, propertyMapper, propertyInstance, propertyObjectName);
|
||||||
instance[key] = serializedValue;
|
instance[key] = serializedValue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,4 +55,4 @@
|
||||||
"unit": "node test/unit.js testlist.txt",
|
"unit": "node test/unit.js testlist.txt",
|
||||||
"jshint": "jshint lib --reporter=jslint"
|
"jshint": "jshint lib --reporter=jslint"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1120,6 +1120,7 @@ describe('msrest', function () {
|
||||||
result.id.should.equal(5);
|
result.id.should.equal(5);
|
||||||
result.status.should.equal(true);
|
result.status.should.equal(true);
|
||||||
result.eyeColor.should.equal('brown');
|
result.eyeColor.should.equal('brown');
|
||||||
|
result.favoriteFood.should.equal('bones');
|
||||||
result.odatalocation.should.equal('westus');
|
result.odatalocation.should.equal('westus');
|
||||||
result.color.should.equal('red');
|
result.color.should.equal('red');
|
||||||
result.city.should.equal('Seattle');
|
result.city.should.equal('Seattle');
|
||||||
|
|
Загрузка…
Ссылка в новой задаче