@sleeksky/alt-swagger 2.2.0 → 2.3.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sleeksky/alt-swagger",
3
- "version": "2.2.0",
3
+ "version": "2.3.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
@@ -121,9 +121,9 @@ function tag(name, description) {
121
121
  tags.push({ name, description });
122
122
  }
123
123
 
124
- function swaggerDoc(title = "API Docs") {
124
+ function swaggerDoc(title) {
125
125
  return {
126
- info: { title, version: "1.0.0" },
126
+ info: { title: title || "", version: "1.0.0" },
127
127
  openapi: "3.0.0",
128
128
  servers,
129
129
  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.default = def;
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
  }
@@ -71,7 +71,7 @@ function pathParameters(str) {
71
71
  }
72
72
 
73
73
  function pathClean(path) {
74
- if (path.match(RX_BRACE)) return path.replace(RX_BRACE, m => `${m.split(":")[0]}}`)
74
+ if (path.match(RX_BRACE)) return path.replace(RX_BRACE, m => `${m.split(/(\:.+)?\}/)[0]}}`)
75
75
  return path;
76
76
  }
77
77