@sleeksky/alt-swagger 2.2.0 → 2.2.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.
- package/package.json +2 -1
- package/src/index.js +4 -3
- package/src/utils.js +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sleeksky/alt-swagger",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.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
|
@@ -63,8 +63,9 @@ function api(opt) {
|
|
|
63
63
|
const summary = (str) => { spec.summary = str; return ext; };
|
|
64
64
|
const desc = (str) => { spec.description = str; return ext; };
|
|
65
65
|
const deprecate = () => { spec.deprecated = true; return ext; };
|
|
66
|
+
const remove = () => { _.unset(paths, `${pathClean(opt.path)}.${opt.method}`); };
|
|
66
67
|
|
|
67
|
-
Object.assign(ext, { req, res, query, header, tag, summary, desc, deprecate });
|
|
68
|
+
Object.assign(ext, { req, res, query, header, tag, summary, desc, deprecate, remove });
|
|
68
69
|
|
|
69
70
|
// support all ext in parameters
|
|
70
71
|
Object.keys(ext).forEach(k => {
|
|
@@ -121,9 +122,9 @@ function tag(name, description) {
|
|
|
121
122
|
tags.push({ name, description });
|
|
122
123
|
}
|
|
123
124
|
|
|
124
|
-
function swaggerDoc(title
|
|
125
|
+
function swaggerDoc(title) {
|
|
125
126
|
return {
|
|
126
|
-
info: { title, version: "1.0.0" },
|
|
127
|
+
info: { title: title || "", version: "1.0.0" },
|
|
127
128
|
openapi: "3.0.0",
|
|
128
129
|
servers,
|
|
129
130
|
tags,
|
package/src/utils.js
CHANGED
|
@@ -38,9 +38,9 @@ function toSwaggerSchema(str) {
|
|
|
38
38
|
if (def !== '') {
|
|
39
39
|
if (type === 'number' || type === 'integer') def = def*1;
|
|
40
40
|
if (type === 'boolean') def = ['true','1'].indexOf(def) > -1 ? true : false;
|
|
41
|
-
schema.
|
|
41
|
+
schema.example = def;
|
|
42
42
|
} else if (optional) {
|
|
43
|
-
schema.default = null;
|
|
43
|
+
// schema.default = null;
|
|
44
44
|
}
|
|
45
45
|
if (!optional) schema.required = true;
|
|
46
46
|
}
|