Skip to content

Commit

Permalink
Merge branch 'feature/swagger-default-description' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil Sturgeon committed Dec 20, 2017
2 parents 6a01f3d + f4da01f commit 6765409
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 24 deletions.
16 changes: 5 additions & 11 deletions src/serializers/swagger/v2.0/Serializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,18 +493,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 Expand Up @@ -1167,7 +1161,7 @@ methods.getResponsesFromRequest = (store, request) => {
if (Object.keys(responses).length === 0) {
return {
default: {
description: 'no response description was provided for this operation'
description: ''
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/serializers/swagger/v2.0/__tests__/Serializer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,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 Expand Up @@ -2408,21 +2408,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: ''
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions testing/e2e/internal-swagger2/e2e.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
})
Expand Down
14 changes: 7 additions & 7 deletions testing/e2e/internal-swagger2/test-case-1/output.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
],
"responses": {
"default": {
"description": "no response description was provided for this operation"
"description": ""
}
},
"security": [
Expand All @@ -55,7 +55,7 @@
],
"responses": {
"default": {
"description": "no response description was provided for this operation"
"description": ""
}
}
}
Expand All @@ -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 @@ -109,7 +109,7 @@
],
"responses": {
"default": {
"description": "no response description was provided for this operation"
"description": ""
}
},
"security": [
Expand All @@ -129,7 +129,7 @@
],
"responses": {
"default": {
"description": "no response description was provided for this operation"
"description": ""
}
}
}
Expand All @@ -142,7 +142,7 @@
],
"responses": {
"200": {
"description": "no description was provided for this response",
"description": "",
"schema": {
"$ref": "#/definitions/SongsLib.Song"
}
Expand Down

0 comments on commit 6765409

Please sign in to comment.