From e5c7afb8eb3bb454e756d4c0041919eda51bbbfb Mon Sep 17 00:00:00 2001 From: Dhroov Gupta Date: Fri, 30 Aug 2019 14:56:18 +0530 Subject: [PATCH] reduced openapi spec file --- lib/deref.js | 14 +++++--------- lib/util.js | 4 ++-- test/data/valid_openapi/readOnly.json | 12 +----------- test/unit/base.test.js | 3 ++- 4 files changed, 10 insertions(+), 23 deletions(-) diff --git a/lib/deref.js b/lib/deref.js index 50e3d1f..f9409fe 100644 --- a/lib/deref.js +++ b/lib/deref.js @@ -164,19 +164,15 @@ module.exports = { continue; } /* eslint-enable */ - tempSchema.properties[prop] = property; - // eslint-disable-next-line max-len - tempSchema.properties[prop] = this.resolveRefs(tempSchema.properties[prop], bodyTypeOption, components, stack); + tempSchema.properties[prop] = this.resolveRefs(property, + bodyTypeOption, components, stack); } } return tempSchema; } - /* eslint-disable no-else-return */ - else { - schema.type = 'string'; - schema.default = ''; - } - /* eslint-enable */ + + schema.type = 'string'; + schema.default = ''; } else if (schema.type === 'array' && schema.items) { diff --git a/lib/util.js b/lib/util.js index 1c2c0b2..809f581 100644 --- a/lib/util.js +++ b/lib/util.js @@ -1135,8 +1135,8 @@ module.exports = { } } - // eslint-disable-next-line max-len - bodyData = this.convertToPmBodyData(contentObj[bodyType], bodyType, BODY_TYPE.REQUEST, this.options.indentCharacter); + bodyData = this.convertToPmBodyData(contentObj[bodyType], bodyType, + BODY_TYPE.REQUEST, this.options.indentCharacter); updateOptions = { mode: rDataMode, diff --git a/test/data/valid_openapi/readOnly.json b/test/data/valid_openapi/readOnly.json index a06fb56..a9c2b9c 100644 --- a/test/data/valid_openapi/readOnly.json +++ b/test/data/valid_openapi/readOnly.json @@ -21,17 +21,7 @@ "type": "array", "items": { "type": "object", - "properties": { - "id": { - "type": "integer", - "format": "int64", - "readOnly": true - }, - "tag": { - "type": "string", - "writeOnly": true - } - } + "$ref": "#/components/schemas/Pet" } } } diff --git a/test/unit/base.test.js b/test/unit/base.test.js index 7c992f8..0b1858e 100644 --- a/test/unit/base.test.js +++ b/test/unit/base.test.js @@ -85,7 +85,8 @@ describe('CONVERT FUNCTION TESTS ', function() { responseBody = conversionResult.output[0].data.item[0].item[0].response[0].body; expect(err).to.be.null; expect(requestBody).to.equal('{\n "name": "",\n "tag": ""\n}'); - expect(responseBody).to.equal('[\n {\n "id": ""\n },\n {\n "id": ""\n }\n]'); + expect(responseBody).to.equal('[\n {\n "id": "",\n "name": ""\n }' + + ',\n {\n "id": "",\n "name": ""\n }\n]'); done(); });