Skip to content

Commit

Permalink
Empty swagger response description is actually fine
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil Sturgeon committed Dec 7, 2017
1 parent 6642994 commit d896613
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
14 changes: 4 additions & 10 deletions src/serializers/swagger/v2.0/Serializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/serializers/swagger/v2.0/__tests__/Serializer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' }
Expand Down
8 changes: 4 additions & 4 deletions testing/e2e/internal-swagger2/test-case-1/output.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
],
"responses": {
"200": {
"description": "no description was provided for this response",
"description": "",
"schema": {
"$ref": "#/definitions/AnotherEntry"
}
Expand All @@ -81,7 +81,7 @@
],
"responses": {
"200": {
"description": "no description was provided for this response",
"description": "",
"schema": {
"type": "object"
}
Expand Down Expand Up @@ -142,7 +142,7 @@
],
"responses": {
"200": {
"description": "no description was provided for this response",
"description": "",
"schema": {
"$ref": "#/definitions/SongsLib.Song"
}
Expand Down Expand Up @@ -768,4 +768,4 @@
"description": "This trait can be used to apply an access token query parameter\nto any resources or HTTP methods.\n"
}
]
}
}

0 comments on commit d896613

Please sign in to comment.