speedly 2.0.32 → 2.0.33
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.
|
@@ -8,6 +8,7 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const swagger_ui_express_1 = __importDefault(require("swagger-ui-express"));
|
|
10
10
|
const swagger_themes_1 = require("swagger-themes");
|
|
11
|
+
const parser_1 = require("./parser");
|
|
11
12
|
const METHODS_WITH_BODY = ["post", "put", "patch"];
|
|
12
13
|
/* ===================== HELPERS ======================= */
|
|
13
14
|
function extractPath(layer) {
|
|
@@ -103,9 +104,7 @@ function routeAnalyzer(route, routerName) {
|
|
|
103
104
|
const scanned = scanRouter(route);
|
|
104
105
|
const paramsRegex = /:[^/]+/g;
|
|
105
106
|
scanned.forEach((route) => {
|
|
106
|
-
const fullPath = `/${routerName}${route.path
|
|
107
|
-
.replace(/^\/$/, "")
|
|
108
|
-
.replaceAll(paramsRegex, (r) => `{${r.slice(1)}}`)}`;
|
|
107
|
+
const fullPath = `/${routerName}${(0, parser_1.expressToSwagger)(route.path)}`;
|
|
109
108
|
routerDetails[fullPath] = {};
|
|
110
109
|
Object.entries(route.methods).forEach(([method, detail]) => {
|
|
111
110
|
const doc = {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function expressToSwagger(path: string): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.expressToSwagger = expressToSwagger;
|
|
4
|
+
function expressToSwagger(path) {
|
|
5
|
+
// مرحله 1: optional group ها رو unwrap کن
|
|
6
|
+
// {/:newName} -> /:newName
|
|
7
|
+
let normalized = path.replace(/\{([^}]+)\}/g, "$1");
|
|
8
|
+
// مرحله 2: :param رو تبدیل کن به {param}
|
|
9
|
+
normalized = normalized.replace(/:([A-Za-z0-9_]+)/g, "{$1}");
|
|
10
|
+
return normalized;
|
|
11
|
+
}
|
|
@@ -8,6 +8,7 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const swagger_ui_express_1 = __importDefault(require("swagger-ui-express"));
|
|
10
10
|
const swagger_themes_1 = require("swagger-themes");
|
|
11
|
+
const parser_1 = require("./parser");
|
|
11
12
|
const METHODS_WITH_BODY = ["post", "put", "patch"];
|
|
12
13
|
/* ===================== HELPERS ======================= */
|
|
13
14
|
function extractPath(layer) {
|
|
@@ -103,9 +104,7 @@ function routeAnalyzer(route, routerName) {
|
|
|
103
104
|
const scanned = scanRouter(route);
|
|
104
105
|
const paramsRegex = /:[^/]+/g;
|
|
105
106
|
scanned.forEach((route) => {
|
|
106
|
-
const fullPath = `/${routerName}${route.path
|
|
107
|
-
.replace(/^\/$/, "")
|
|
108
|
-
.replaceAll(paramsRegex, (r) => `{${r.slice(1)}}`)}`;
|
|
107
|
+
const fullPath = `/${routerName}${(0, parser_1.expressToSwagger)(route.path)}`;
|
|
109
108
|
routerDetails[fullPath] = {};
|
|
110
109
|
Object.entries(route.methods).forEach(([method, detail]) => {
|
|
111
110
|
const doc = {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function expressToSwagger(path: string): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.expressToSwagger = expressToSwagger;
|
|
4
|
+
function expressToSwagger(path) {
|
|
5
|
+
// مرحله 1: optional group ها رو unwrap کن
|
|
6
|
+
// {/:newName} -> /:newName
|
|
7
|
+
let normalized = path.replace(/\{([^}]+)\}/g, "$1");
|
|
8
|
+
// مرحله 2: :param رو تبدیل کن به {param}
|
|
9
|
+
normalized = normalized.replace(/:([A-Za-z0-9_]+)/g, "{$1}");
|
|
10
|
+
return normalized;
|
|
11
|
+
}
|