@necessarylion/adonis-autoswagger 0.0.15 → 0.0.17

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/dist/file.d.ts CHANGED
@@ -40,5 +40,5 @@ export declare class FileService {
40
40
  * @param files_ string[]
41
41
  * @returns
42
42
  */
43
- getFiles(dir: string, files_?: string[]): Promise<string[]>;
43
+ getFiles(dir: string, files_?: string[], ignoreFiles?: string[]): Promise<string[]>;
44
44
  }
package/dist/file.js CHANGED
@@ -74,17 +74,22 @@ class FileService {
74
74
  * @param files_ string[]
75
75
  * @returns
76
76
  */
77
- async getFiles(dir, files_) {
77
+ async getFiles(dir, files_, ignoreFiles) {
78
78
  const fs = require("fs");
79
79
  files_ = files_ || [];
80
80
  var files = await fs.readdirSync(dir);
81
81
  for (let i in files) {
82
82
  var name = dir + "/" + files[i];
83
83
  if (fs.statSync(name).isDirectory()) {
84
- await this.getFiles(name, files_);
84
+ await this.getFiles(name, files_, ignoreFiles);
85
85
  }
86
86
  else {
87
- files_.push(name);
87
+ if (ignoreFiles && ignoreFiles.some((pattern) => name.includes(pattern))) {
88
+ // skip
89
+ }
90
+ else {
91
+ files_.push(name);
92
+ }
88
93
  }
89
94
  }
90
95
  return files_;
@@ -108,7 +108,6 @@ class ValidatorParser {
108
108
  const type = property["type"];
109
109
  const field = property["fieldName"];
110
110
  if (type === "object") {
111
- console.log(field, property);
112
111
  obj[field] = { type: "object", ...this.#parseSchema(property, refs) };
113
112
  }
114
113
  else {
package/dist/schema.js CHANGED
@@ -151,7 +151,11 @@ class SchemaService {
151
151
  if ((0, fs_2.existsSync)(p6)) {
152
152
  p = p6;
153
153
  }
154
- const files = await this.fileService.getFiles(p, []);
154
+ const files = await this.fileService.getFiles(p, [], this.options.models?.ignores);
155
+ const modelPaths = this.options.models?.paths ?? [];
156
+ for (const modelPath of modelPaths) {
157
+ files.push(...await this.fileService.getFiles(path_1.default.join(this.options.appPath, modelPath), [], this.options.models?.ignores));
158
+ }
155
159
  const readFile = util_1.default.promisify(fs_1.default.readFile);
156
160
  if (this.options.debug) {
157
161
  console.log("Found model files", files);
package/dist/types.d.ts CHANGED
@@ -21,6 +21,10 @@ export interface options {
21
21
  authMiddlewares?: string[];
22
22
  defaultSecurityScheme?: string;
23
23
  pagniationData?: Record<string, any>;
24
+ models?: {
25
+ paths: string[];
26
+ ignores: string[];
27
+ };
24
28
  }
25
29
  export interface common {
26
30
  headers: any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@necessarylion/adonis-autoswagger",
3
- "version": "0.0.15",
3
+ "version": "0.0.17",
4
4
  "description": "Auto-Generate swagger docs for AdonisJS",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",