Repository: BRIKEV/express-jsdoc-swagger (js)

Issue:
[BUG] No way to provide empty response body as return example
**Describe the bug**
When describing an endpoint, there is no way to define an empty response body

**To Reproduce**
```js
Add a docblock with the following content
/**
 * DELETE /api/v1/products/{id}
 * @summary Delete product with specific ID
 * @tags Products
 * @param {number} id.path.required
 * @return 201 - Success Response
 */
```

**Expected behavior**
Produces a swagger response example with an empty body

**Actual behavior**
Produces example response with a `"string"` body. In the case of an empty response body, this section should be empty.
<details>
<summary>Screenshots</summary>
<img width="765" alt="Screen Shot 2021-06-14 at 5 59 45 PM" src="https://user-images.githubusercontent.com/1687902/121965460-0ecccf00-cd3b-11eb-8fb4-220fa44172c6.png">

The following is an example from another Swagger API doc with an empty response:
<img width="799" alt="Screen Shot 2021-06-14 at 6 08 37 PM" src="https://user-images.githubusercontent.com/1687902/121965818-a0d4d780-cd3b-11eb-9ba8-88c47cd1d962.png">
</details>

It's worth noting that if you attempt any of the following comments, the Swagger docs fail to render and display an error:

```js
/**
 * fails to build docs:
 * @return {undefined} 201 - Success Response
 * @return {null} 201 - Success Response
 * 
 * displays "string" as body type:
 * @return {void} 201 - Success Response
 * @return 201 - Success Response
 */
```

Pull request:
Feat/add empty responses
### What kind of change does this PR introduce? (check at least one)
 - [X] Bugfix
 - [X] Feature
 - [X] Test
 
### Description:

This PR allows the option to provide an empty response in the OpenAPI Docs. This is possible using the OpenAPI `yml`.

In order to do this, we have to use this comment.

```js
/**
 * GET /api/v1
 * @summary This is the summary of the endpoint
 * @return 200 - success response - application/json
 * @return 400 - Bad request response
 */
```

This closes #165 



Patch:
diff --git a/transforms/paths/responses.js b/transforms/paths/responses.js
index ce7d90b..7cc245d 100644
--- a/transforms/paths/responses.js
+++ b/transforms/paths/responses.js
@@ -25,10 +25,12 @@ const formatResponses = (values, examples) => values.reduce((acc, value) => {
     ...acc,
     [status]: {
       description,
-      content: {
-        ...(hasOldContent(acc, status) ? { ...acc[status].content } : {}),
-        ...getContent(value.type, contentType, value.description, exampleList),
-      },
+      ...(value.type ? {
+        content: {
+          ...(hasOldContent(acc, status) ? { ...acc[status].content } : {}),
+          ...getContent(value.type, contentType, value.description, exampleList),
+        },
+      } : {}),
     },
   };
 }, {});


Test patch:
diff --git a/test/e2e/errors/errors.test.js b/test/e2e/errors/errors.test.js
index 1d8d2c6..536b580 100644
--- a/test/e2e/errors/errors.test.js
+++ b/test/e2e/errors/errors.test.js
@@ -2,31 +2,6 @@
 const chalk = require('chalk');
 const processSwagger = require('../../../processSwagger');
 
-test('should give a nice error message for responses', async () => {
-  const options = {
-    info: {
-      version: '1.0.0',
-      title: 'Albums store',
-      license: {
-        name: 'MIT',
-      },
-    },
-    filesPattern: './jsdoc-response-error.js',
-    baseDir: __dirname,
-  };
-  global.console = { ...global.console, warn: jest.fn() };
-  await processSwagger(options);
-  expect(console.warn).toHaveBeenCalledTimes(2);
-  expect(console.warn).toHaveBeenNthCalledWith(
-    1,
-    chalk.yellow('[express-jsdoc-swagger] Entity: @return could not be parsed. Value: "200 - success response - application/json" is wrong'),
-  );
-  expect(console.warn).toHaveBeenNthCalledWith(
-    2,
-    chalk.yellow('[express-jsdoc-swagger] Entity: @return could not be parsed. Value: "400 - Bad request response" is wrong'),
-  );
-});
-
 test('should give a nice error message for parameters', async () => {
   const options = {
     info: {
diff --git a/test/e2e/errors/jsdoc-response-error.js b/test/e2e/errors/jsdoc-response-error.js
deleted file mode 100644
index 30b8b85..0000000
--- a/test/e2e/errors/jsdoc-response-error.js
+++ /dev/null
@@ -1,6 +0,0 @@
-/**
- * GET /api/v1/album
- * @summary This is the summary of the endpoint
- * @return 200 - success response - application/json
- * @return 400 - Bad request response
- */
diff --git a/test/transforms/paths/responses.test.js b/test/transforms/paths/responses.test.js
index 84d641e..46dae98 100644
--- a/test/transforms/paths/responses.test.js
+++ b/test/transforms/paths/responses.test.js
@@ -3,6 +3,42 @@ const jsdocInfo = require('../../../consumers/jsdocInfo');
 const setPaths = require('../../../transforms/paths');
 
 describe('response tests', () => {
+  it('should parse jsdoc path spec with more than one response without type', () => {
+    const jsodInput = [`
+      /**
+       * GET /api/v1
+       * @summary This is the summary of the endpoint
+       * @return 200 - success response - application/json
+       * @return 400 - Bad request response
+       */
+    `];
+    const expected = {
+      paths: {
+        '/api/v1': {
+          get: {
+            deprecated: false,
+            summary: 'This is the summary of the endpoint',
+            parameters: [],
+            tags: [],
+            security: [],
+            responses: {
+              200: {
+                description: 'success response',
+              },
+              400: {
+                description: 'Bad request response',
+              },
+            },
+          },
+        },
+      },
+    };
+    const parsedJSDocs = jsdocInfo()(jsodInput);
+    const result = setPaths({}, parsedJSDocs);
+    expect(result)
+      .toEqual(expected);
+  });
+
   it('should parse jsdoc path spec with more than one response', () => {
     const jsodInput = [`
       /**