Files
admin/patches/adonis-autoswagger+3.73.0.patch
T
2026-06-25 15:53:49 +03:00

139 lines
4.7 KiB
Diff

diff --git a/node_modules/adonis-autoswagger/dist/autoswagger.js b/node_modules/adonis-autoswagger/dist/autoswagger.js
index a02dcf1..63a232a 100644
--- a/node_modules/adonis-autoswagger/dist/autoswagger.js
+++ b/node_modules/adonis-autoswagger/dist/autoswagger.js
@@ -49,6 +49,8 @@ const scalarCustomCss_1 = require("./scalarCustomCss");
const adonishelpers_1 = require("./adonishelpers");
const parsers_1 = require("./parsers");
const helpers_1 = require("./helpers");
+const { join } = require("path");
+const path = require("path");
const example_1 = __importStar(require("./example"));
class AutoSwagger {
options;
@@ -584,7 +586,14 @@ class AutoSwagger {
}
return validators;
}
- const files = await this.getFiles(p6, []);
+
+ const modulePath = await this.getModulePath()
+
+ const base_files = await this.getFiles(p6, []);
+ const modules_files = await this.getModulesFilesByType(modulePath, [], 'validators');
+
+ var files = [...base_files, ...modules_files]
+
if (this.options.debug) {
console.log("Found validator files", files);
}
@@ -657,7 +666,14 @@ class AutoSwagger {
if ((0, fs_2.existsSync)(p6)) {
p = p6;
}
- const files = await this.getFiles(p, []);
+
+ const modulePath = await this.getModulePath()
+
+ const base_files = await this.getFiles(p6, []);
+ const modules_files = await this.getModulesFilesByType(modulePath, [], 'models');
+
+ const files = [...base_files, ...modules_files]
+
const readFile = util_1.default.promisify(fs_1.default.readFile);
if (this.options.debug) {
console.log("Found model files", files);
@@ -703,7 +719,13 @@ class AutoSwagger {
if ((0, fs_2.existsSync)(p6)) {
p = p6;
}
- const files = await this.getFiles(p, []);
+ const modulePath = await this.getModulePath()
+
+ const base_files = await this.getFiles(p6, []);
+ const modules_files = await this.getModulesFilesByType(modulePath, [], 'interfaces');
+
+ var files = [...base_files, ...modules_files]
+
if (this.options.debug) {
console.log("Found interfaces files", files);
}
@@ -753,7 +775,14 @@ class AutoSwagger {
if ((0, fs_2.existsSync)(p6)) {
p = p6;
}
- const files = await this.getFiles(p, []);
+
+ const modulePath = await this.getModulePath()
+
+ const base_files = await this.getFiles(p6, []);
+ const modules_files = await this.getModulesFilesByType(modulePath, [], 'types');
+
+ var files = [...base_files, ...modules_files]
+ console.log('all files',files)
if (this.options.debug) {
console.log("Found enum files", files);
}
@@ -773,5 +802,44 @@ class AutoSwagger {
}
return enums;
}
+ async getModulePath() {
+ var modulePath = join(this.options.appPath, "modules")
+ if (typeof this.customPaths["#modules"] !== "undefined"){
+ return modulePath.replace("app/modules", this.customPaths['#modules'])
+ }
+ return modulePath
+ }
+
+ async getModulesFilesByType(dir, files_, type) {
+ console.log('in nodemodukes', dir, files_, type)
+ const fs = require("fs");
+ files_ = files_ || [];
+ var files = await fs.readdirSync(dir);
+
+ var paths = []
+
+ if (typeof this.options?.modulesPath?.[type] !== 'undefined') {
+ paths = this.options?.modulesPath[type]
+ } else {
+ paths = [type]
+ }
+
+ for (let i in files) {
+ var name = dir + "/" + files[i];
+
+ if (fs.statSync(name).isDirectory()) {
+ for(var path of paths) {
+ console.log('path',name+ "/" + path)
+ if (fs.existsSync(name + "/" + path)) {
+ await this.getFiles(name + "/" + path, files_);
+ }
+ }
+ }
+ else {
+ files_.push(name);
+ }
+ }
+ return files_;
+ }
}
exports.AutoSwagger = AutoSwagger;
diff --git a/node_modules/adonis-autoswagger/dist/types.d.ts b/node_modules/adonis-autoswagger/dist/types.d.ts
index b6b6982..96948c2 100644
--- a/node_modules/adonis-autoswagger/dist/types.d.ts
+++ b/node_modules/adonis-autoswagger/dist/types.d.ts
@@ -20,6 +20,12 @@ export interface options {
productionEnv?: string;
authMiddlewares?: string[];
defaultSecurityScheme?: string;
+ modulesPath?: {
+ models?: string[],
+ interfaces?: string[],
+ validators?: string[],
+ types?: string[],
+ },
}
export interface common {
headers: any;