Repository: BRIKEV/express-jsdoc-swagger
Pull request #9 (2020-05-31 17:26:55)

feat: add deprecated option for each endpoint
This PR includes new feature for each option. The possibility of desecrating endpoints by adding.

```
* @deprecated
```



Patch:
diff --git a/transforms/paths/index.js b/transforms/paths/index.js
index 2a6af9c..7156940 100644
--- a/transforms/paths/index.js
+++ b/transforms/paths/index.js
@@ -16,6 +16,8 @@ const parsePath = path => {
   const lowerCaseMethod = method.toLowerCase();
   const { tags } = path;
   const summary = getTagInfo(tags, 'summary');
+  const deprecated = getTagInfo(tags, 'deprecated');
+  const isDeprecated = !!deprecated;
   const returnValues = getTagsInfo(tags, 'return');
   const paramValues = getTagsInfo(tags, 'param');
   const tagsValues = getTagsInfo(tags, 'tags');
@@ -24,6 +26,7 @@ const parsePath = path => {
   return {
     [endpoint]: {
       [lowerCaseMethod]: {
+        deprecated: isDeprecated,
         summary: summary && summary.description ? summary.description : '',
         responses,
         parameters,


Test patch:
diff --git a/test/transforms/paths/index.test.js b/test/transforms/paths/index.test.js
index def6c24..6633454 100644
--- a/test/transforms/paths/index.test.js
+++ b/test/transforms/paths/index.test.js
@@ -34,6 +34,45 @@ describe('setPaths method', () => {
       paths: {
         '/api/v1': {
           get: {
+            deprecated: false,
+            summary: 'This is the summary or description of the endpoint',
+            parameters: [],
+            tags: [],
+            responses: {
+              200: {
+                description: 'success response',
+                content: {
+                  'application/json': {
+                    schema: {
+                      type: 'object',
+                    },
+                  },
+                },
+              },
+            },
+          },
+        },
+      },
+    };
+    const parsedJSDocs = jsdocInfo()(jsodInput);
+    const result = setPaths({}, parsedJSDocs);
+    expect(result).toEqual(expected);
+  });
+
+  it('should parse jsdoc path spec with deprecated value', () => {
+    const jsodInput = [`
+      /**
+       * GET /api/v1
+       * @deprecated
+       * @summary This is the summary or description of the endpoint
+       * @return {object} 200 - success response - application/json
+       */
+    `];
+    const expected = {
+      paths: {
+        '/api/v1': {
+          get: {
+            deprecated: true,
             summary: 'This is the summary or description of the endpoint',
             parameters: [],
             tags: [],
diff --git a/test/transforms/paths/parameters.test.js b/test/transforms/paths/parameters.test.js
index c4c1e12..c2763a7 100644
--- a/test/transforms/paths/parameters.test.js
+++ b/test/transforms/paths/parameters.test.js
@@ -13,6 +13,7 @@ describe('params tests', () => {
       paths: {
         '/api/v1': {
           get: {
+            deprecated: false,
             summary: '',
             responses: {},
             tags: [],
@@ -47,6 +48,7 @@ describe('params tests', () => {
       paths: {
         '/api/v1': {
           get: {
+            deprecated: false,
             summary: '',
             responses: {},
             tags: [],
@@ -71,6 +73,7 @@ describe('params tests', () => {
       paths: {
         '/api/v1': {
           get: {
+            deprecated: false,
             summary: '',
             responses: {},
             tags: [],
@@ -109,6 +112,7 @@ describe('params tests', () => {
       paths: {
         '/api/v1': {
           get: {
+            deprecated: false,
             summary: '',
             responses: {},
             tags: [],
@@ -156,6 +160,7 @@ describe('params tests', () => {
       paths: {
         '/api/v1': {
           get: {
+            deprecated: false,
             summary: '',
             responses: {},
             tags: [],
@@ -190,6 +195,7 @@ describe('params tests', () => {
       paths: {
         '/api/v1': {
           get: {
+            deprecated: false,
             summary: '',
             responses: {},
             tags: [],
diff --git a/test/transforms/paths/requestBody.test.js b/test/transforms/paths/requestBody.test.js
index 34473bd..d24762e 100644
--- a/test/transforms/paths/requestBody.test.js
+++ b/test/transforms/paths/requestBody.test.js
@@ -13,6 +13,7 @@ describe('request body tests', () => {
       paths: {
         '/api/v1': {
           post: {
+            deprecated: false,
             summary: '',
             responses: {},
             tags: [],
@@ -48,6 +49,7 @@ describe('request body tests', () => {
       paths: {
         '/api/v1': {
           post: {
+            deprecated: false,
             summary: '',
             responses: {},
             tags: [],
@@ -87,6 +89,7 @@ describe('request body tests', () => {
       paths: {
         '/api/v1': {
           post: {
+            deprecated: false,
             summary: '',
             responses: {},
             tags: [],
@@ -125,6 +128,7 @@ describe('request body tests', () => {
       paths: {
         '/api/v1': {
           post: {
+            deprecated: false,
             summary: '',
             responses: {},
             tags: [],
@@ -160,6 +164,7 @@ describe('request body tests', () => {
       paths: {
         '/api/v1': {
           post: {
+            deprecated: false,
             summary: '',
             responses: {},
             tags: [],
@@ -199,6 +204,7 @@ describe('request body tests', () => {
       paths: {
         '/api/v1': {
           post: {
+            deprecated: false,
             summary: '',
             responses: {},
             tags: [],
diff --git a/test/transforms/paths/responses.test.js b/test/transforms/paths/responses.test.js
index c970da6..9341653 100644
--- a/test/transforms/paths/responses.test.js
+++ b/test/transforms/paths/responses.test.js
@@ -15,6 +15,7 @@ describe('response tests', () => {
       paths: {
         '/api/v1': {
           get: {
+            deprecated: false,
             summary: 'This is the summary or description of the endpoint',
             parameters: [],
             tags: [],
@@ -62,6 +63,7 @@ describe('response tests', () => {
       paths: {
         '/api/v1': {
           get: {
+            deprecated: false,
             summary: 'This is the summary or description of the endpoint',
             responses: {},
             parameters: [],
@@ -89,6 +91,7 @@ describe('response tests', () => {
       paths: {
         '/api/v1': {
           get: {
+            deprecated: false,
             summary: 'This is the summary or description of the endpoint',
             parameters: [],
             tags: [],
@@ -128,6 +131,7 @@ describe('response tests', () => {
       paths: {
         '/api/v1': {
           get: {
+            deprecated: false,
             summary: 'This is the summary or description of the endpoint',
             parameters: [],
             tags: [],
@@ -164,6 +168,7 @@ describe('response tests', () => {
       paths: {
         '/api/v1': {
           get: {
+            deprecated: false,
             summary: 'This is the summary or description of the endpoint',
             parameters: [],
             tags: [],
@@ -205,6 +210,7 @@ describe('response tests', () => {
       paths: {
         '/api/v1': {
           get: {
+            deprecated: false,
             summary: 'This is the summary or description of the endpoint',
             parameters: [],
             tags: [],
diff --git a/test/transforms/paths/tags.test.js b/test/transforms/paths/tags.test.js
index b56ae96..90bf544 100644
--- a/test/transforms/paths/tags.test.js
+++ b/test/transforms/paths/tags.test.js
@@ -13,6 +13,7 @@ describe('Paths - tags', () => {
       paths: {
         '/api/v1': {
           get: {
+            deprecated: false,
             summary: '',
             tags: [
               'album',
@@ -40,6 +41,7 @@ describe('Paths - tags', () => {
       paths: {
         '/api/v1': {
           get: {
+            deprecated: false,
             summary: '',
             tags: [
               'album',