@necessarylion/adonis-autoswagger 0.0.14 → 0.0.16

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/example.d.ts CHANGED
@@ -60,61 +60,5 @@ export declare abstract class ExampleInterfaces {
60
60
  * Pagination interface
61
61
  * @returns
62
62
  */
63
- static paginationInterface(): {
64
- PaginationMeta: {
65
- type: string;
66
- properties: {
67
- total: {
68
- type: string;
69
- example: number;
70
- nullable: boolean;
71
- };
72
- page: {
73
- type: string;
74
- example: number;
75
- nullable: boolean;
76
- };
77
- perPage: {
78
- type: string;
79
- example: number;
80
- nullable: boolean;
81
- };
82
- currentPage: {
83
- type: string;
84
- example: number;
85
- nullable: boolean;
86
- };
87
- lastPage: {
88
- type: string;
89
- example: number;
90
- nullable: boolean;
91
- };
92
- firstPage: {
93
- type: string;
94
- example: number;
95
- nullable: boolean;
96
- };
97
- lastPageUrl: {
98
- type: string;
99
- example: string;
100
- nullable: boolean;
101
- };
102
- firstPageUrl: {
103
- type: string;
104
- example: string;
105
- nullable: boolean;
106
- };
107
- nextPageUrl: {
108
- type: string;
109
- example: string;
110
- nullable: boolean;
111
- };
112
- previousPageUrl: {
113
- type: string;
114
- example: string;
115
- nullable: boolean;
116
- };
117
- };
118
- };
119
- };
63
+ static paginationInterface(snakeCase?: boolean): Record<string, any>;
120
64
  }
package/dist/example.js CHANGED
@@ -362,7 +362,38 @@ class ExampleInterfaces {
362
362
  * Pagination interface
363
363
  * @returns
364
364
  */
365
- static paginationInterface() {
365
+ static paginationInterface(snakeCase = false) {
366
+ if (snakeCase) {
367
+ return {
368
+ PaginationMeta: {
369
+ type: "object",
370
+ properties: {
371
+ total: { type: "number", example: 100, nullable: false },
372
+ page: { type: "number", example: 2, nullable: false },
373
+ per_page: { type: "number", example: 10, nullable: false },
374
+ current_page: { type: "number", example: 3, nullable: false },
375
+ last_page: { type: "number", example: 10, nullable: false },
376
+ first_page: { type: "number", example: 1, nullable: false },
377
+ last_page_url: {
378
+ type: "string",
379
+ example: "/?page=10",
380
+ nullable: false,
381
+ },
382
+ first_page_url: {
383
+ type: "string",
384
+ example: "/?page=1",
385
+ nullable: false,
386
+ },
387
+ next_page_url: { type: "string", example: "/?page=6", nullable: false },
388
+ previous_page_url: {
389
+ type: "string",
390
+ example: "/?page=5",
391
+ nullable: false,
392
+ },
393
+ },
394
+ },
395
+ };
396
+ }
366
397
  return {
367
398
  PaginationMeta: {
368
399
  type: "object",
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_;
package/dist/schema.js CHANGED
@@ -151,7 +151,12 @@ 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
+ }
159
+ console.log(files);
155
160
  const readFile = util_1.default.promisify(fs_1.default.readFile);
156
161
  if (this.options.debug) {
157
162
  console.log("Found model files", files);
@@ -187,7 +192,7 @@ class SchemaService {
187
192
  */
188
193
  async getInterfaces() {
189
194
  let interfaces = {
190
- ...example_1.ExampleInterfaces.paginationInterface(),
195
+ ...example_1.ExampleInterfaces.paginationInterface(this.options.snakeCase),
191
196
  };
192
197
  let p = path_1.default.join(this.options.appPath, "Interfaces");
193
198
  let p6 = path_1.default.join(this.options.appPath, "interfaces");
package/dist/types.d.ts CHANGED
@@ -20,6 +20,11 @@ export interface options {
20
20
  productionEnv?: string;
21
21
  authMiddlewares?: string[];
22
22
  defaultSecurityScheme?: string;
23
+ pagniationData?: Record<string, any>;
24
+ models?: {
25
+ paths: string[];
26
+ ignores: string[];
27
+ };
23
28
  }
24
29
  export interface common {
25
30
  headers: any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@necessarylion/adonis-autoswagger",
3
- "version": "0.0.14",
3
+ "version": "0.0.16",
4
4
  "description": "Auto-Generate swagger docs for AdonisJS",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",