@necessarylion/adonis-autoswagger 0.0.3 → 0.0.4

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.
@@ -41,9 +41,10 @@ const json_to_pretty_yaml_1 = __importDefault(require("json-to-pretty-yaml"));
41
41
  const fs_1 = __importDefault(require("fs"));
42
42
  const path_1 = __importDefault(require("path"));
43
43
  const util_1 = __importDefault(require("util"));
44
+ const lodash_1 = require("lodash");
44
45
  const http_status_code_1 = __importDefault(require("http-status-code"));
45
- const lodash_1 = __importDefault(require("lodash"));
46
- const lodash_2 = require("lodash");
46
+ const lodash_2 = __importDefault(require("lodash"));
47
+ const lodash_3 = require("lodash");
47
48
  const fs_2 = require("fs");
48
49
  const scalarCustomCss_1 = require("./scalarCustomCss");
49
50
  const adonishelpers_1 = require("./adonishelpers");
@@ -356,10 +357,9 @@ class AutoSwagger {
356
357
  return;
357
358
  globalTags.push({
358
359
  name: tag,
359
- description: "Everything related to " + tag,
360
360
  });
361
361
  });
362
- const { sourceFile, action, customAnnotations, operationId } = await this.getDataBasedOnAdonisVersion(route);
362
+ let { sourceFile, action, customAnnotations, operationId } = await this.getDataBasedOnAdonisVersion(route);
363
363
  route.methods.forEach((method) => {
364
364
  let responses = {};
365
365
  if (method === "HEAD")
@@ -398,12 +398,11 @@ class AutoSwagger {
398
398
  parameters = (0, helpers_1.mergeParams)(parameters, actionParams);
399
399
  if (tag != "") {
400
400
  globalTags.push({
401
- name: tag.toUpperCase(),
402
- description: "Everything related to " + tag.toUpperCase(),
401
+ name: tag.toUpperCase()
403
402
  });
404
403
  tags = [tag.toUpperCase()];
405
404
  }
406
- if ((0, lodash_2.isEmpty)(responses)) {
405
+ if ((0, lodash_3.isEmpty)(responses)) {
407
406
  responses[responseCodes[method]] = {
408
407
  description: http_status_code_1.default.getMessage(responseCodes[method]),
409
408
  content: {
@@ -454,9 +453,10 @@ class AutoSwagger {
454
453
  break;
455
454
  }
456
455
  }
456
+ action = (0, lodash_1.startCase)(action);
457
457
  const sf = sourceFile.split("/").at(-1).replace(".ts", "");
458
458
  let m = {
459
- summary: `${summary}${action !== "" ? ` (${action})` : "route"}`,
459
+ summary: `${summary}${action !== "" ? ` ${action}` : "route"}`,
460
460
  description: description + "\n\n _" + sourceFile + "_ - **" + action + "**",
461
461
  operationId: operationId,
462
462
  parameters: parameters,
@@ -478,7 +478,7 @@ class AutoSwagger {
478
478
  });
479
479
  }
480
480
  // filter unused tags
481
- const usedTags = lodash_1.default.uniq(Object.entries(paths)
481
+ const usedTags = lodash_2.default.uniq(Object.entries(paths)
482
482
  .map(([p, val]) => Object.entries(val)[0][1].tags)
483
483
  .flat());
484
484
  docs.tags = globalTags.filter((tag) => usedTags.includes(tag.name));
@@ -497,7 +497,7 @@ class AutoSwagger {
497
497
  sourceFile = route.meta.resolvedHandler.namespace;
498
498
  action = route.meta.resolvedHandler.method;
499
499
  // If not defined by an annotation, use the combination of "controllerNameMethodName"
500
- if (action !== "" && (0, lodash_2.isUndefined)(operationId) && route.handler) {
500
+ if (action !== "" && (0, lodash_3.isUndefined)(operationId) && route.handler) {
501
501
  operationId = (0, helpers_1.formatOperationId)(route.handler);
502
502
  }
503
503
  }
@@ -548,7 +548,7 @@ class AutoSwagger {
548
548
  if (this.options.debug) {
549
549
  if (sourceFile !== "") {
550
550
  console.log(typeof customAnnotations !== "undefined" &&
551
- !lodash_1.default.isEmpty(customAnnotations)
551
+ !lodash_2.default.isEmpty(customAnnotations)
552
552
  ? `\x1b[32m✓ FOUND for ${action}\x1b[0m`
553
553
  : `\x1b[33m✗ MISSING for ${action}\x1b[0m`, `${sourceFile} (${route.methods[0].toUpperCase()} ${route.pattern})`);
554
554
  }
@@ -682,6 +682,8 @@ class AutoSwagger {
682
682
  if (parsed.required.length > 0) {
683
683
  schema['required'] = parsed.required;
684
684
  }
685
+ if (name.toLowerCase().includes('readme.md'))
686
+ continue;
685
687
  models[name] = schema;
686
688
  }
687
689
  return models;
package/dist/example.js CHANGED
@@ -262,6 +262,8 @@ class ExampleGenerator {
262
262
  return this.exampleByField("date");
263
263
  case "object":
264
264
  return {};
265
+ case "uuid":
266
+ return this.exampleByField("uuid");
265
267
  default:
266
268
  return null;
267
269
  }
@@ -292,6 +294,7 @@ class ExampleGenerator {
292
294
  price: 10.5,
293
295
  avatar: "https://example.com/avatar.png",
294
296
  url: "https://example.com",
297
+ uuid: "2b0bf725-d404-481f-b431-17f1182a5e57"
295
298
  };
296
299
  if (typeof ex[field] !== "undefined") {
297
300
  return ex[field];
package/dist/parsers.js CHANGED
@@ -621,6 +621,11 @@ class ModelParser {
621
621
  type = "string";
622
622
  format = "date";
623
623
  }
624
+ if (type === "uuid") {
625
+ indicator = "type";
626
+ type = "string";
627
+ format = "uuid";
628
+ }
624
629
  if (field === "email") {
625
630
  indicator = "type";
626
631
  type = "string";
@@ -1 +1 @@
1
- export declare const scalarCustomCss = "\n/* basic theme */\n.light-mode {\n --theme-background-1: #fff;\n --theme-background-2: #fafaf9;\n --theme-background-3: rgb(245 245 245);\n\n --theme-color-1: #21201c;\n --theme-color-2: #63635d;\n --theme-color-3: #8e8e8e;\n\n --theme-color-accent: #5a45ff;\n --theme-background-accent: #5a45ff1f;\n\n --theme-border-color: color(display-p3 0.913 0.912 0.903);\n --theme-code-language-color-supersede: var(--theme-color-1);\n --theme-code-languages-background-supersede: var(--theme-background-3);\n}\n.dark-mode {\n --theme-background-1: #0f0f0f;\n --theme-background-2: #222222;\n --theme-background-3: #272727;\n\n --theme-color-1: #e2e4e8;\n --theme-color-2: rgba(255, 255, 255, 0.62);\n --theme-color-3: #6a737d;\n\n --theme-color-accent: #e2ddfe;\n --theme-background-accent: #3c2d6a;\n\n --theme-border-color: rgba(255, 255, 255, 0.1);\n --theme-code-language-color-supersede: var(--theme-color-1);\n --theme-code-languages-background-supersede: var(--theme-background-3);\n}\n\n/* Document Sidebar */\n.light-mode .t-doc__sidebar,\n.dark-mode .t-doc__sidebar {\n --sidebar-background-1: var(--theme-background-1);\n --sidebar-color-1: var(--theme-color-1);\n --sidebar-color-2: var(--theme-color-2);\n --sidebar-border-color: var(--theme-border-color);\n\n --sidebar-item-hover-background: var(--theme-background-2);\n --sidebar-item-hover-color: currentColor;\n\n --sidebar-item-active-background: var(--theme-background-accent);\n --sidebar-color-active: var(--theme-color-accent);\n\n --sidebar-search-background: var(--theme-background-2);\n --sidebar-search-color: var(--theme-color-3);\n --sidebar-search-border-color: var(--theme-border-color);\n}\n\n/* advanced */\n.light-mode {\n --theme-color-green: #0e766e;\n --theme-color-red: #e53935;\n --theme-color-yellow: #e2931d;\n --theme-color-blue: #0f766e;\n --theme-color-orange: #f76d47;\n --theme-color-purple: #4338ca;\n}\n.dark-mode {\n --theme-color-green: #0ad8b6;\n --theme-color-red: #e5484d;\n --theme-color-yellow: #eac063;\n --theme-color-blue: #6abaff;\n --theme-color-orange: #ff9b52;\n --theme-color-purple: #6550b9;\n}\n/* custom-theme */\n.show-api-client-button:before {\n background: white !important;\n}\n.show-api-client-button span,\n.show-api-client-button svg {\n color: var(--theme-background-1) !important;\n}\n.section:not(:last-of-type),\n.section-container {\n border-top: none !important;\n border-bottom: none !important;\n}\n.section-container:after,\n.tag-section-container section.section:after {\n content: \"\";\n width: 100%;\n height: 1px;\n position: absolute;\n top: 0;\n left: 0;\n background: repeating-linear-gradient(\n 90deg,\n var(--theme-border-color) 0 4px,\n transparent 0 8px\n );\n}\n.section-container:nth-of-type(2):after {\n display: none;\n}\n.tag-section-container .section:first-of-type:after {\n display: none;\n}\n.sidebar {\n border-right: none !important;\n}\n.t-doc__sidebar {\n position: relative;\n}\n.t-doc__sidebar:after {\n content: \"\";\n width: 1px;\n height: 100%;\n position: absolute;\n right: 0;\n top: 0;\n background: repeating-linear-gradient(\n 0deg,\n var(--theme-border-color) 0 4px,\n transparent 0 8px\n );\n display: block;\n}\n.download-cta .download-button,\n.scalar-api-reference .section .markdown a {\n --theme-color-accent: var(--theme-color-1) !important;\n text-decoration: underline !important;\n cursor: pointer;\n}";
1
+ export declare const scalarCustomCss = "\n/* basic theme */\n.light-mode {\n --theme-background-1: #fff;\n --theme-background-2: #fafaf9;\n --theme-background-3: rgb(245 245 245);\n\n --theme-color-1: #21201c;\n --theme-color-2: #63635d;\n --theme-color-3: #8e8e8e;\n\n --theme-color-accent: #5a45ff;\n --theme-background-accent: #5a45ff1f;\n\n --theme-border-color: color(display-p3 0.913 0.912 0.903);\n --theme-code-language-color-supersede: var(--theme-color-1);\n --theme-code-languages-background-supersede: var(--theme-background-3);\n}\n.dark-mode {\n --theme-background-1: #0f0f0f;\n --theme-background-2: #222222;\n --theme-background-3: #272727;\n\n --theme-color-1: #e2e4e8;\n --theme-color-2: rgba(255, 255, 255, 0.62);\n --theme-color-3: #6a737d;\n\n --theme-color-accent: #e2ddfe;\n --theme-background-accent: #3c2d6a;\n\n --theme-border-color: rgba(255, 255, 255, 0.1);\n --theme-code-language-color-supersede: var(--theme-color-1);\n --theme-code-languages-background-supersede: var(--theme-background-3);\n}\n\n/* Document Sidebar */\n.light-mode .t-doc__sidebar,\n.dark-mode .t-doc__sidebar {\n --sidebar-background-1: var(--theme-background-1);\n --sidebar-color-1: var(--theme-color-1);\n --sidebar-color-2: var(--theme-color-2);\n --sidebar-border-color: var(--theme-border-color);\n\n --sidebar-item-hover-background: var(--theme-background-2);\n --sidebar-item-hover-color: currentColor;\n\n --sidebar-item-active-background: var(--theme-background-accent);\n --sidebar-color-active: var(--theme-color-accent);\n\n --sidebar-search-background: var(--theme-background-2);\n --sidebar-search-color: var(--theme-color-3);\n --sidebar-search-border-color: var(--theme-border-color);\n}\n\n/* advanced */\n.light-mode {\n --theme-color-green: #0e766e;\n --theme-color-red: #e53935;\n --theme-color-yellow: #e2931d;\n --theme-color-blue: #0f766e;\n --theme-color-orange: #f76d47;\n --theme-color-purple: #4338ca;\n}\n.dark-mode {\n --theme-color-green: #0ad8b6;\n --theme-color-red: #e5484d;\n --theme-color-yellow: #eac063;\n --theme-color-blue: #6abaff;\n --theme-color-orange: #ff9b52;\n --theme-color-purple: #6550b9;\n}\n/* custom-theme */\n.show-api-client-button:before {\n background: white !important;\n}\n.show-api-client-button span,\n.show-api-client-button svg {\n color: var(--theme-background-1) !important;\n}\n.section:not(:last-of-type),\n.section-container {\n border-top: none !important;\n border-bottom: none !important;\n}\n.section-container:after,\n.tag-section-container section.section:after {\n content: \"\";\n width: 100%;\n height: 1px;\n position: absolute;\n top: 0;\n left: 0;\n background: repeating-linear-gradient(\n 90deg,\n var(--theme-border-color) 0 4px,\n transparent 0 8px\n );\n}\n.section-container:nth-of-type(2):after {\n display: none;\n}\n.tag-section-container .section:first-of-type:after {\n display: none;\n}\n.sidebar {\n border-right: none !important;\n}\n.t-doc__sidebar {\n position: relative;\n}\n.t-doc__sidebar:after {\n content: \"\";\n width: 1px;\n height: 100%;\n position: absolute;\n right: 0;\n top: 0;\n background: repeating-linear-gradient(\n 0deg,\n var(--theme-border-color) 0 4px,\n transparent 0 8px\n );\n display: block;\n}\n.download-cta .download-button,\n.scalar-api-reference .section .markdown a {\n --theme-color-accent: var(--theme-color-1) !important;\n text-decoration: underline !important;\n cursor: pointer;\n}\n.sidebar-heading-link[tabindex=\"-1\"] .sidebar-heading-link-title {\n font-weight: bold !important;\n font-family: monospace;\n text-transform: uppercase;\n}\n.scalar .scalar-app-layout {\n max-width: 95% !important;\n box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px !important;\n}\n.scalar-container {\n background: #434343d4 !important; \n}\n";
@@ -130,4 +130,17 @@ exports.scalarCustomCss = `
130
130
  --theme-color-accent: var(--theme-color-1) !important;
131
131
  text-decoration: underline !important;
132
132
  cursor: pointer;
133
- }`;
133
+ }
134
+ .sidebar-heading-link[tabindex="-1"] .sidebar-heading-link-title {
135
+ font-weight: bold !important;
136
+ font-family: monospace;
137
+ text-transform: uppercase;
138
+ }
139
+ .scalar .scalar-app-layout {
140
+ max-width: 95% !important;
141
+ box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px !important;
142
+ }
143
+ .scalar-container {
144
+ background: #434343d4 !important;
145
+ }
146
+ `;
package/dist/types.js CHANGED
@@ -9,6 +9,7 @@ exports.standardTypes = [
9
9
  "date",
10
10
  "boolean",
11
11
  "any",
12
+ "uuid",
12
13
  ]
13
14
  .map((type) => [type, type + "[]"])
14
15
  .flat();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@necessarylion/adonis-autoswagger",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "Auto-Generate swagger docs for AdonisJS",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",