Repository: BRIKEV/express-jsdoc-swagger
Pull request #68 (2020-06-15 22:32:36)

Enforcer validation
### What kind of change does this PR introduce? (check at least one)
 - [ ] Bugfix
 - [X] Feature
 - [ ] Test
 - [X] Docs
 - [ ] Refactor
 - [ ] Build-related changes
 - [ ] Other, please describe:

### Description:

This PR includes:

- Docs improvement (Some errors after using openapi-enforcer validator)
- Remove `allowEmptyValue`  support. This tag will be removed in future versions. 

This closes #68 



Patch:
diff --git a/README.md b/README.md
index 1cb8375..b77dcda 100644
--- a/README.md
+++ b/README.md
@@ -91,7 +91,7 @@ const options = {
  * @typedef {object} Song
  * @property {string} title.required - The title
  * @property {string} artist - The artist
- * @property {number} year - The year - int64
+ * @property {number} year - The year - double
  */
 ```
 
diff --git a/examples/combineSchemas/index.js b/examples/combineSchemas/index.js
index 89da0c6..5273898 100644
--- a/examples/combineSchemas/index.js
+++ b/examples/combineSchemas/index.js
@@ -25,7 +25,7 @@ expressJSDocSwagger(app)(options);
  * @typedef {object} IntrumentalSong
  * @property {string} title.required - The title
  * @property {string} band - The band
- * @property {number} year - The year - int64
+ * @property {number} year - The year - double
  */
 
 /**
@@ -33,13 +33,14 @@ expressJSDocSwagger(app)(options);
  * @typedef {object} PopSong
  * @property {string} title.required - The title
  * @property {string} artist - The artist
- * @property {number} year - The year - int64
+ * @property {integer} year - The year - int64
  */
 
 /**
  * GET /api/v1/song/{id}
  * @summary This is the summary or description of the endpoint
  * @tags album
+ * @param {number} id.path - song id
  * @return {oneOf|IntrumentalSong|PopSong} 200 - success response - application/json
  */
 app.get('/api/v1/song/:id', (req, res) => (
diff --git a/examples/components/enum.js b/examples/components/enum.js
index 2ce5b0d..168cf9e 100644
--- a/examples/components/enum.js
+++ b/examples/components/enum.js
@@ -25,7 +25,8 @@ expressJSDocSwagger(app)(options);
  * @typedef {object} Song
  * @property {string} title.required - The title
  * @property {string} artist - The artist
- * @property {string} license - The year - int64 - enum:ISC,MIT
+ * @property {number} artist - The artist - double
+ * @property {string} license - The year - enum:ISC,MIT
  */
 
 /**
@@ -33,7 +34,7 @@ expressJSDocSwagger(app)(options);
  * @typedef {object} Author
  * @property {string} name.required - Author name
  * @property {string} role - enum:singer,guitarrist - The author role
- * @property {number} age - Author age - int64
+ * @property {integer} age - Author age - int64
  */
 
 /**
diff --git a/examples/components/simple.js b/examples/components/simple.js
index edbb5b6..5e65e60 100644
--- a/examples/components/simple.js
+++ b/examples/components/simple.js
@@ -25,14 +25,14 @@ expressJSDocSwagger(app)(options);
  * @typedef {object} Song
  * @property {string} title.required - The title
  * @property {string} artist - The artist
- * @property {number} year - The year - int64
+ * @property {integer} year - The year - int64
  */
 
 /**
  * Author model
  * @typedef {object} Author
  * @property {string} name.required - Author name
- * @property {number} age - Author age - int64
+ * @property {number} age - Author age - double
  */
 
 /**
diff --git a/examples/merge/simple.js b/examples/merge/simple.js
index 59c1e1b..ea0f226 100644
--- a/examples/merge/simple.js
+++ b/examples/merge/simple.js
@@ -32,8 +32,8 @@ expressJSDocSwagger(app)(options, userSwagger);
 /**
  * GET /api/v1/albums
  * @summary This is the summary or description of the endpoint
- * @param {array<Song>} name.query.required - name param description
- * @return {array<Song>} 200 - success response - application/json
+ * @param {array<object>} name.query.required - name param description
+ * @return {array<object>} 200 - success response - application/json
  */
 app.get('/api/v1/albums', (req, res) => (
   res.json([{
diff --git a/examples/parameters/components.js b/examples/parameters/components.js
index fd2bc22..537a2c4 100644
--- a/examples/parameters/components.js
+++ b/examples/parameters/components.js
@@ -25,7 +25,7 @@ expressJSDocSwagger(app)(options);
  * @typedef {object} Song
  * @property {string} title.required - The title
  * @property {string} artist - The artist
- * @property {number} year - The year - int64
+ * @property {integer} year - The year - int64
  */
 
 /**
diff --git a/examples/parameters/multiple.js b/examples/parameters/multiple.js
index 4feb305..7fcdd3c 100644
--- a/examples/parameters/multiple.js
+++ b/examples/parameters/multiple.js
@@ -21,22 +21,22 @@ const port = 3000;
 expressJSDocSwagger(app)(options);
 
 /**
- * GET /api/v1
+ * GET /api/v1/{id}
  * @summary This is the summary or description of the endpoint
  * @param {string} name.query.required - name param description
- * @param {number} phone.param - phone number
+ * @param {number} id.path - phone number
  * @return {string} 200 - success response
  */
-app.get('/api/v1', (req, res) => res.send('Hello World!'));
+app.get('/api/v1/:id', (req, res) => res.send('Hello World!'));
 
 /**
- * GET /api/v1/albums
+ * GET /api/v1/albums/{id}
  * @summary This is the summary or description of the endpoint
  * @param {array<string>} name.query.required.deprecated - name param description
- * @param {number} phone.param
+ * @param {number} id.path
  * @return {object} 200 - success response - application/json
  */
-app.get('/api/v1/albums', (req, res) => (
+app.get('/api/v1/albums/:id', (req, res) => (
   res.json([{
     title: 'abum 1',
   }])
diff --git a/examples/requestBody/components.js b/examples/requestBody/components.js
index 40c16a1..ca50eae 100644
--- a/examples/requestBody/components.js
+++ b/examples/requestBody/components.js
@@ -25,18 +25,20 @@ expressJSDocSwagger(app)(options);
  * @typedef {object} Song
  * @property {string} title.required - The title
  * @property {string} artist - The artist
- * @property {number} year - The year - int64
+ * @property {integer} year - The year - int64
  */
 
 /**
  * POST /api/v1/song
  * @param {Song} request.body.required - song info
+ * @return {object} 200 - song response
  */
 app.post('/api/v1/songs', (req, res) => res.send('You save a song!'));
 
 /**
  * POST /api/v1/album
  * @param {array<Song>} request.body.required - songs info
+ * @return {object} 200 - album response
  */
 app.post('/api/v1/album', (req, res) => res.send('You save a song!'));
 
diff --git a/examples/requestBody/formdata.js b/examples/requestBody/formdata.js
index a54c573..d04af92 100644
--- a/examples/requestBody/formdata.js
+++ b/examples/requestBody/formdata.js
@@ -26,12 +26,13 @@ expressJSDocSwagger(app)(options);
  * @property {string} title.required - The title
  * @property {string} artist - The artist
  * @property {string} cover - image cover - binary
- * @property {number} year - The year - int64
+ * @property {integer} year - The year - int64
  */
 
 /**
  * POST /api/v1/album
  * @param {Song} request.body.required - songs info - multipart/form-data
+ * @return {object} 200 - Album created
  */
 app.post('/api/v1/album', (req, res) => res.send('You save a song!'));
 
diff --git a/examples/requestBody/multiple.js b/examples/requestBody/multiple.js
index c3fd28b..2fbaea7 100644
--- a/examples/requestBody/multiple.js
+++ b/examples/requestBody/multiple.js
@@ -23,10 +23,11 @@ expressJSDocSwagger(app)(options);
 // This one includes a mix of params and requestBody
 
 /**
- * POST /api/v1
+ * POST /api/v1/album
  * @param {number} body.query
  * @param {array<string>} request.body.required - name body description
+ * @return {object} 200 - album response
  */
-app.post('/api/v1', (req, res) => res.send('Hello World!'));
+app.post('/api/v1/album', (req, res) => res.send('Hello World!'));
 
 app.listen(port, () => logger.info(`Example app listening at http://localhost:${port}`));
diff --git a/examples/requestBody/simple.js b/examples/requestBody/simple.js
index 5da296b..c2a858f 100644
--- a/examples/requestBody/simple.js
+++ b/examples/requestBody/simple.js
@@ -21,15 +21,17 @@ const port = 3000;
 expressJSDocSwagger(app)(options);
 
 /**
- * POST /api/v1
+ * POST /api/v1/songs
  * @param {string} request.body.required - name body description
+ * @return {object} 200 - song response
  */
-app.post('/api/v1', (req, res) => res.send('Hello World!'));
+app.post('/api/v1/songs', (req, res) => res.send('Hello World!'));
 
 /**
  * POST /api/v1/albums
  * @param {array<object>} request.body.required
+ * @return {object} 200 - song response
  */
-app.post('/api/v1', (req, res) => res.send('Hello World!'));
+app.post('/api/v1/albums', (req, res) => res.send('Hello World!'));
 
 app.listen(port, () => logger.info(`Example app listening at http://localhost:${port}`));
diff --git a/examples/responses/components.js b/examples/responses/components.js
index 911793f..4bd3960 100644
--- a/examples/responses/components.js
+++ b/examples/responses/components.js
@@ -25,7 +25,7 @@ expressJSDocSwagger(app)(options);
  * @typedef {object} Song
  * @property {string} title.required - The title
  * @property {string} artist - The artist
- * @property {number} year - The year - int64
+ * @property {integer} year - The year - int64
  */
 
 /**
diff --git a/examples/tags/simple.js b/examples/tags/simple.js
index 60394a8..737e24e 100644
--- a/examples/tags/simple.js
+++ b/examples/tags/simple.js
@@ -23,18 +23,21 @@ expressJSDocSwagger(app)(options);
 /**
  * GET /api/v1/album
  * @tags Album
+ * @return {object} 200 - album response
  */
 
 /**
  * GET /api/v1/songs
  * @tags Album
  * @tags Songs
+ * @return {object} 200 - album response
  */
 
 /**
  * POST /api/v1/song
  * @summary Create new song
  * @tags Songs - everything about songs
+ * @return {object} 200 - album response
  */
 
 /**
@@ -42,6 +45,7 @@ expressJSDocSwagger(app)(options);
  * @param {number} songId.path.required - song id
  * @summary Edit song
  * @tags Songs
+ * @return {object} 200 - album response
  */
 
 /**
@@ -49,6 +53,7 @@ expressJSDocSwagger(app)(options);
  * @param {number} songId.path.required - song id
  * @summary Delete song
  * @tags Songs
+ * @return {object} 200 - album response
  */
 
 /**
@@ -56,6 +61,7 @@ expressJSDocSwagger(app)(options);
  * @param {number} songId.path.required - song id
  * @summary Get song detail
  * @tags Songs
+ * @return {object} 200 - album response
  */
 
 app.listen(port, () => logger.info(`Example app listening at http://localhost:${port}`));
diff --git a/transforms/paths/parameters.js b/transforms/paths/parameters.js
index 5ce7b11..a7e036e 100644
--- a/transforms/paths/parameters.js
+++ b/transforms/paths/parameters.js
@@ -5,7 +5,6 @@ const formatDescription = require('../utils/formatDescription');
 const getSchema = require('./schema');
 
 const REQUIRED = 'required';
-const ALLOW_EMPTY_VALUE = 'allowEmptyValue';
 const DEPRECATED = 'deprecated';
 const BODY_PARAM = 'body';
 
@@ -32,10 +31,6 @@ const parameterPayload = (options, schema) => ({
     type: 'boolean',
     defaultValue: false,
   }),
-  allowEmptyValue: setProperty(options, 'allowEmptyValue', {
-    type: 'boolean',
-    defaultValue: false,
-  }),
   schema,
 });
 
@@ -56,14 +51,12 @@ const parseParameter = param => {
     return wrongInOption(param.name);
   }
   const isRequired = extraOptions.includes(REQUIRED);
-  const allowEmptyValue = extraOptions.includes(ALLOW_EMPTY_VALUE);
   const isDeprecated = extraOptions.includes(DEPRECATED);
   const [description, enumValues] = formatDescription(param.description);
   const options = {
     name,
     in: inOption,
     required: isRequired,
-    allowEmptyValue,
     deprecated: isDeprecated,
     description,
   };


Test patch:
diff --git a/test/e2e/parameters/parameters.test.js b/test/e2e/parameters/parameters.test.js
index 3a8b428..2867e7d 100644
--- a/test/e2e/parameters/parameters.test.js
+++ b/test/e2e/parameters/parameters.test.js
@@ -49,7 +49,6 @@ test('should parse components jsdoc from jsdoc-example', async () => {
               description: 'name param description',
               required: true,
               deprecated: false,
-              allowEmptyValue: false,
               schema: {
                 type: 'string',
               },
@@ -60,7 +59,6 @@ test('should parse components jsdoc from jsdoc-example', async () => {
               description: 'phone number',
               required: false,
               deprecated: false,
-              allowEmptyValue: false,
               schema: {
                 type: 'number',
               },
@@ -93,7 +91,6 @@ test('should parse components jsdoc from jsdoc-example', async () => {
               description: 'name param description',
               required: true,
               deprecated: true,
-              allowEmptyValue: false,
               schema: {
                 type: 'array',
                 items: {
@@ -107,7 +104,6 @@ test('should parse components jsdoc from jsdoc-example', async () => {
               description: '',
               required: false,
               deprecated: false,
-              allowEmptyValue: false,
               schema: {
                 type: 'number',
               },
diff --git a/test/transforms/paths/combineSchemas.test.js b/test/transforms/paths/combineSchemas.test.js
index 9140ecb..08df0c2 100644
--- a/test/transforms/paths/combineSchemas.test.js
+++ b/test/transforms/paths/combineSchemas.test.js
@@ -170,7 +170,6 @@ test('should parse jsdoc path reference params with allOf keyword', () => {
           tags: [],
           security: [],
           parameters: [{
-            allowEmptyValue: false,
             deprecated: false,
             description: 'name param description',
             in: 'query',
diff --git a/test/transforms/paths/parameters.test.js b/test/transforms/paths/parameters.test.js
index e6d46c1..21c5f93 100644
--- a/test/transforms/paths/parameters.test.js
+++ b/test/transforms/paths/parameters.test.js
@@ -19,7 +19,6 @@ describe('params tests', () => {
             tags: [],
             security: [],
             parameters: [{
-              allowEmptyValue: false,
               deprecated: false,
               description: 'name param description',
               in: 'query',
@@ -81,7 +80,6 @@ describe('params tests', () => {
             tags: [],
             security: [],
             parameters: [{
-              allowEmptyValue: false,
               deprecated: true,
               description: 'name param description',
               in: 'query',
@@ -121,7 +119,6 @@ describe('params tests', () => {
             tags: [],
             security: [],
             parameters: [{
-              allowEmptyValue: false,
               deprecated: true,
               description: 'name param description',
               in: 'query',
@@ -134,7 +131,6 @@ describe('params tests', () => {
                 },
               },
             }, {
-              allowEmptyValue: false,
               deprecated: false,
               description: '',
               in: 'param',
@@ -170,7 +166,6 @@ describe('params tests', () => {
             tags: [],
             security: [],
             parameters: [{
-              allowEmptyValue: false,
               deprecated: false,
               description: 'name param description',
               in: 'query',
@@ -206,7 +201,6 @@ describe('params tests', () => {
             tags: [],
             security: [],
             parameters: [{
-              allowEmptyValue: false,
               deprecated: true,
               description: 'name param description',
               in: 'query',
@@ -245,7 +239,6 @@ describe('params tests', () => {
             tags: [],
             security: [],
             parameters: [{
-              allowEmptyValue: false,
               deprecated: false,
               description: 'name param description',
               in: 'query',
@@ -285,7 +278,6 @@ describe('params tests', () => {
             tags: [],
             security: [],
             parameters: [{
-              allowEmptyValue: false,
               deprecated: false,
               description: 'name param description',
               in: 'query',