forked from loafle/openapi-generator-original
[JavaScript] Fixed handling of empty arrays/empty strings/booleans/single numbers as valid API responses (#4653) (#4666)
This commit is contained in:
@@ -317,7 +317,7 @@
|
||||
// Rely on SuperAgent for parsing response body.
|
||||
// See http://visionmedia.github.io/superagent/#parsing-response-bodies
|
||||
var data = response.body;
|
||||
if (data == null || !Object.keys(data).length) {
|
||||
if (data == null || (typeof data === 'object' && typeof data.length === 'undefined' && !Object.keys(data).length)) {
|
||||
// SuperAgent does not always produce a body; use the unparsed response as a fallback
|
||||
data = response.text;
|
||||
}
|
||||
|
||||
@@ -320,7 +320,7 @@
|
||||
// Rely on SuperAgent for parsing response body.
|
||||
// See http://visionmedia.github.io/superagent/#parsing-response-bodies
|
||||
var data = response.body;
|
||||
if (data == null || !Object.keys(data).length) {
|
||||
if (data == null || (typeof data === 'object' && typeof data.length === 'undefined' && !Object.keys(data).length)) {
|
||||
// SuperAgent does not always produce a body; use the unparsed response as a fallback
|
||||
data = response.text;
|
||||
}
|
||||
|
||||
@@ -320,7 +320,7 @@
|
||||
// Rely on SuperAgent for parsing response body.
|
||||
// See http://visionmedia.github.io/superagent/#parsing-response-bodies
|
||||
var data = response.body;
|
||||
if (data == null || !Object.keys(data).length) {
|
||||
if (data == null || (typeof data === 'object' && typeof data.length === 'undefined' && !Object.keys(data).length)) {
|
||||
// SuperAgent does not always produce a body; use the unparsed response as a fallback
|
||||
data = response.text;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user