mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-10 23:52:45 +00:00
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:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user