@sleeksky/alt-swagger 2.3.0 → 2.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +2 -1
  2. package/src/index.js +10 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sleeksky/alt-swagger",
3
- "version": "2.3.0",
3
+ "version": "2.3.2",
4
4
  "description": "Quickly spec your APIs for Swagger / OpenAPI interface",
5
5
  "main": "./src/index.js",
6
6
  "scripts": {
@@ -37,6 +37,7 @@
37
37
  "swagger-ui-express": "^4.1.6"
38
38
  },
39
39
  "dependencies": {
40
+ "@sleeksky/alt-schema": "^2.1.0",
40
41
  "lodash": "^4.17.21"
41
42
  },
42
43
  "peerDependencies": {
package/src/index.js CHANGED
@@ -22,11 +22,14 @@ function server(url, description) {
22
22
  }
23
23
 
24
24
  function api(opt) {
25
- const spec = { parameters: [], responses: {}, description: "" };
26
- const pathParams = pathParameters(opt.path);
27
- if (pathParams.length > 0) spec.parameters = pathParams;
28
-
29
- _.set(paths, `${pathClean(opt.path)}.${opt.method}`, spec);
25
+ let path = `${pathClean(opt.path)}.${opt.method}`;
26
+ let spec = _.get(paths, path, false);
27
+ if (!spec) {
28
+ spec = { parameters: [], responses: {}, description: "" };
29
+ const pathParams = pathParameters(opt.path);
30
+ if (pathParams.length > 0) spec.parameters = pathParams;
31
+ _.set(paths, path, spec);
32
+ }
30
33
 
31
34
  let ext = {};
32
35
 
@@ -63,8 +66,9 @@ function api(opt) {
63
66
  const summary = (str) => { spec.summary = str; return ext; };
64
67
  const desc = (str) => { spec.description = str; return ext; };
65
68
  const deprecate = () => { spec.deprecated = true; return ext; };
69
+ const remove = () => { _.unset(paths, `${pathClean(opt.path)}.${opt.method}`); };
66
70
 
67
- Object.assign(ext, { req, res, query, header, tag, summary, desc, deprecate });
71
+ Object.assign(ext, { req, res, query, header, tag, summary, desc, deprecate, remove });
68
72
 
69
73
  // support all ext in parameters
70
74
  Object.keys(ext).forEach(k => {