Skip to content

Commit 82919bb

Browse files
committed
fix scenario only for */*
1 parent 0593b6b commit 82919bb

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

lib/schemaUtils.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ const { formatDataPath, checkIsCorrectType, isKnownType } = require('./common/sc
100100
{ compareVersion } = require('./common/versionUtils.js'),
101101
parse = require('./parse'),
102102
{ getBundleContentAndComponents, parseFileOrThrow } = require('./bundle.js'),
103-
MULTI_FILE_API_TYPE_ALLOWED_VALUE = 'multiFile';
103+
MULTI_FILE_API_TYPE_ALLOWED_VALUE = 'multiFile',
104+
MEDIA_TYPE_ALL_RANGES = '*/*';
104105
/* eslint-enable */
105106

106107
// See https://github.com/json-schema-faker/json-schema-faker/tree/master/docs#available-options
@@ -1375,14 +1376,20 @@ module.exports = {
13751376
responseBody = JSON.stringify(responseBody, null, options.indentCharacter);
13761377
}
13771378
else if (typeof responseBody !== 'string') {
1378-
if (!_.isObject(responseBody) && _.isFunction(_.get(responseBody, 'toString'))) {
1379-
responseBody = responseBody.toString();
1379+
if (cTypeHeader === MEDIA_TYPE_ALL_RANGES) {
1380+
if (!_.isObject(responseBody) && _.isFunction(_.get(responseBody, 'toString'))) {
1381+
responseBody = responseBody.toString();
1382+
}
1383+
else {
1384+
responseBody = JSON.stringify(responseBody, null, options.indentCharacter);
1385+
isJsonLike = true;
1386+
}
13801387
}
13811388
else {
1382-
responseBody = JSON.stringify(responseBody, null, options.indentCharacter);
1383-
isJsonLike = true;
1389+
responseBody = '';
13841390
}
13851391
}
1392+
13861393
return {
13871394
contentTypeHeader: cTypeHeader,
13881395
responseBody: responseBody,

0 commit comments

Comments
 (0)