@sleeksky/alt-swagger 2.4.0 → 2.5.0

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 +1 -1
  2. package/src/index.js +13 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sleeksky/alt-swagger",
3
- "version": "2.4.0",
3
+ "version": "2.5.0",
4
4
  "description": "Quickly spec your APIs for Swagger / OpenAPI interface",
5
5
  "main": "./src/index.js",
6
6
  "scripts": {
package/src/index.js CHANGED
@@ -110,6 +110,18 @@ function del(path = "", opt = {}) {
110
110
  return api(opt);
111
111
  }
112
112
 
113
+ function remove({path=null, tag=null}) {
114
+ if (path) _.unset(paths, `${pathClean(path)}`);
115
+ if (tag) {
116
+ // remote all the paths with this tag
117
+ Object.keys(paths).forEach(p => {
118
+ Object.keys(paths[p]).forEach(method => {
119
+ if (paths[p][method].tags && paths[p][method].tags.includes(tag)) _.unset(paths[p], method);
120
+ })
121
+ });
122
+ }
123
+ }
124
+
113
125
  function security(name, {type = "http", schema = "bearer", bearerFormat = null, required = true}) {
114
126
  components.securitySchemes = components.securitySchemes || {};
115
127
  components.securitySchemes[name] = { type, scheme: schema, bearerFormat, "in": "header", required };
@@ -155,4 +167,5 @@ module.exports = {
155
167
  security,
156
168
  swaggerDoc,
157
169
  reset,
170
+ remove,
158
171
  };