Skip to content
This repository was archived by the owner on Sep 17, 2025. It is now read-only.

Commit d896613

Browse files
author
Phil Sturgeon
committed
Empty swagger response description is actually fine
1 parent 6642994 commit d896613

File tree

3 files changed

+9
-15
lines changed

3 files changed

+9
-15
lines changed

src/serializers/swagger/v2.0/Serializer.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -463,18 +463,12 @@ methods.getSchemaFromResponse = (response) => {
463463
* @returns {SwaggerResponseObject} the corresponding swagger response object.
464464
*/
465465
methods.convertResponseRecordToResponseObject = (store, { key, value }) => {
466-
const response = {}
467-
468-
if (value.get('description')) {
469-
response.description = value.get('description')
470-
}
471-
else {
472-
response.description = 'no description was provided for this response'
466+
const response = {
467+
description: value.get('description') || '',
468+
headers: methods.getHeadersFromResponse(store, value),
469+
schema: methods.getSchemaFromResponse(value),
473470
}
474471

475-
response.headers = methods.getHeadersFromResponse(store, value)
476-
response.schema = methods.getSchemaFromResponse(value)
477-
478472
return {
479473
key,
480474
value: response

src/serializers/swagger/v2.0/__tests__/Serializer.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ describe('serializers/swagger/v2.0/Serializer.js', () => {
653653
}
654654

655655
const expectedValue = {
656-
description: 'no description was provided for this response',
656+
description: '',
657657
headers: {
658658
userId: { type: 'string' },
659659
petId: { type: 'number' }

testing/e2e/internal-swagger2/test-case-1/output.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
],
6868
"responses": {
6969
"200": {
70-
"description": "no description was provided for this response",
70+
"description": "",
7171
"schema": {
7272
"$ref": "#/definitions/AnotherEntry"
7373
}
@@ -81,7 +81,7 @@
8181
],
8282
"responses": {
8383
"200": {
84-
"description": "no description was provided for this response",
84+
"description": "",
8585
"schema": {
8686
"type": "object"
8787
}
@@ -142,7 +142,7 @@
142142
],
143143
"responses": {
144144
"200": {
145-
"description": "no description was provided for this response",
145+
"description": "",
146146
"schema": {
147147
"$ref": "#/definitions/SongsLib.Song"
148148
}
@@ -768,4 +768,4 @@
768768
"description": "This trait can be used to apply an access token query parameter\nto any resources or HTTP methods.\n"
769769
}
770770
]
771-
}
771+
}

0 commit comments

Comments
 (0)