Fix Issue 4554 - handle 204 server response in javascript (#4604)

* issues 4554: Handle 204 response and handle deserialize exceptions

* issue-4554: generate javascript client updated template

Used petstore-with-fake-endpoints-models-for-testing.yaml

* use petstore-with-fake-endpoints-models-for-testing.yaml like sh script
This commit is contained in:
tharders
2017-01-23 08:14:06 +01:00
committed by wing328
parent 8e71dfb512
commit 30315c8570
3 changed files with 19 additions and 7 deletions

View File

@@ -314,7 +314,7 @@
* @returns A value of the specified type.
*/
exports.prototype.deserialize = function deserialize(response, returnType) {
if (response == null || returnType == null) {
if (response == null || returnType == null || response.status == 204) {
return null;
}
// Rely on SuperAgent for parsing response body.
@@ -413,7 +413,11 @@
if (callback) {
var data = null;
if (!error) {
data = _this.deserialize(response, returnType);
try {
data = _this.deserialize(response, returnType);
} catch (err) {
error = err;
}
}
callback(error, data, response);
}