From f4da01f067c5a730eca02ec1297fc3d04d2d4fc6 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Thu, 7 Dec 2017 14:36:15 -0500 Subject: [PATCH] Empty swagger response description is actually fine --- src/serializers/swagger/v2.0/Serializer.js | 16 +++++----------- .../swagger/v2.0/__tests__/Serializer.spec.js | 8 ++++---- testing/e2e/internal-swagger2/e2e.spec.js | 3 +-- .../internal-swagger2/test-case-1/output.json | 14 +++++++------- 4 files changed, 17 insertions(+), 24 deletions(-) diff --git a/src/serializers/swagger/v2.0/Serializer.js b/src/serializers/swagger/v2.0/Serializer.js index 0cf162b..8fc9052 100644 --- a/src/serializers/swagger/v2.0/Serializer.js +++ b/src/serializers/swagger/v2.0/Serializer.js @@ -463,18 +463,12 @@ methods.getSchemaFromResponse = (response) => { * @returns {SwaggerResponseObject} the corresponding swagger response object. */ methods.convertResponseRecordToResponseObject = (store, { key, value }) => { - const response = {} - - if (value.get('description')) { - response.description = value.get('description') - } - else { - response.description = 'no description was provided for this response' + const response = { + description: value.get('description') || '', + headers: methods.getHeadersFromResponse(store, value), + schema: methods.getSchemaFromResponse(value) } - response.headers = methods.getHeadersFromResponse(store, value) - response.schema = methods.getSchemaFromResponse(value) - return { key, value: response @@ -1123,7 +1117,7 @@ methods.getResponsesFromRequest = (store, request) => { if (Object.keys(responses).length === 0) { return { default: { - description: 'no response description was provided for this operation' + description: '' } } } diff --git a/src/serializers/swagger/v2.0/__tests__/Serializer.spec.js b/src/serializers/swagger/v2.0/__tests__/Serializer.spec.js index 055ab64..a036e25 100644 --- a/src/serializers/swagger/v2.0/__tests__/Serializer.spec.js +++ b/src/serializers/swagger/v2.0/__tests__/Serializer.spec.js @@ -653,7 +653,7 @@ describe('serializers/swagger/v2.0/Serializer.js', () => { } const expectedValue = { - description: 'no description was provided for this response', + description: '', headers: { userId: { type: 'string' }, petId: { type: 'number' } @@ -1703,21 +1703,21 @@ describe('serializers/swagger/v2.0/Serializer.js', () => { get: { responses: { default: { - description: 'no response description was provided for this operation' + description: '' } } }, post: { responses: { default: { - description: 'no response description was provided for this operation' + description: '' } } }, put: { responses: { default: { - description: 'no response description was provided for this operation' + description: '' } } } diff --git a/testing/e2e/internal-swagger2/e2e.spec.js b/testing/e2e/internal-swagger2/e2e.spec.js index 882e69a..f698da1 100644 --- a/testing/e2e/internal-swagger2/e2e.spec.js +++ b/testing/e2e/internal-swagger2/e2e.spec.js @@ -81,8 +81,7 @@ describe('internal -> swagger v2', () => { } catch (e) { console.error(e.stack) - expect(true).toEqual(false) - done() + done(new Error('unexpected error')) } /* eslint-enable no-console */ }) diff --git a/testing/e2e/internal-swagger2/test-case-1/output.json b/testing/e2e/internal-swagger2/test-case-1/output.json index 607cb61..3193461 100644 --- a/testing/e2e/internal-swagger2/test-case-1/output.json +++ b/testing/e2e/internal-swagger2/test-case-1/output.json @@ -29,7 +29,7 @@ ], "responses": { "default": { - "description": "no response description was provided for this operation" + "description": "" } }, "security": [ @@ -55,7 +55,7 @@ ], "responses": { "default": { - "description": "no response description was provided for this operation" + "description": "" } } } @@ -67,7 +67,7 @@ ], "responses": { "200": { - "description": "no description was provided for this response", + "description": "", "schema": { "$ref": "#/definitions/AnotherEntry" } @@ -81,7 +81,7 @@ ], "responses": { "200": { - "description": "no description was provided for this response", + "description": "", "schema": { "type": "object" } @@ -109,7 +109,7 @@ ], "responses": { "default": { - "description": "no response description was provided for this operation" + "description": "" } }, "security": [ @@ -129,7 +129,7 @@ ], "responses": { "default": { - "description": "no response description was provided for this operation" + "description": "" } } } @@ -142,7 +142,7 @@ ], "responses": { "200": { - "description": "no description was provided for this response", + "description": "", "schema": { "$ref": "#/definitions/SongsLib.Song" }