speedly 2.0.33 → 2.0.35
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.
|
@@ -102,7 +102,6 @@ function scanRouter(router, base = "") {
|
|
|
102
102
|
function routeAnalyzer(route, routerName) {
|
|
103
103
|
const routerDetails = {};
|
|
104
104
|
const scanned = scanRouter(route);
|
|
105
|
-
const paramsRegex = /:[^/]+/g;
|
|
106
105
|
scanned.forEach((route) => {
|
|
107
106
|
const fullPath = `/${routerName}${(0, parser_1.expressToSwagger)(route.path)}`;
|
|
108
107
|
routerDetails[fullPath] = {};
|
|
@@ -112,6 +111,16 @@ function routeAnalyzer(route, routerName) {
|
|
|
112
111
|
description: "Public route",
|
|
113
112
|
};
|
|
114
113
|
const validation = detail.middlewares.find((mw) => mw.handle?.__validationSchema)?.handle.__validationSchema;
|
|
114
|
+
const pathParams = [...fullPath.matchAll(/{([^}]+)}/g)].map((m) => m[1]);
|
|
115
|
+
if (pathParams.length) {
|
|
116
|
+
doc.parameters = pathParams.map((name) => ({
|
|
117
|
+
name,
|
|
118
|
+
in: "path",
|
|
119
|
+
required: validation?.params?.fields?.[name]?.spec?.optional == false ||
|
|
120
|
+
!new RegExp(`\\{[^\\}]*${name}[^\\}]*\\}`).test(route.path),
|
|
121
|
+
schema: { type: "string" },
|
|
122
|
+
}));
|
|
123
|
+
}
|
|
115
124
|
// If body exists
|
|
116
125
|
if (METHODS_WITH_BODY.includes(method)) {
|
|
117
126
|
if (validation?.body) {
|
|
@@ -102,7 +102,6 @@ function scanRouter(router, base = "") {
|
|
|
102
102
|
function routeAnalyzer(route, routerName) {
|
|
103
103
|
const routerDetails = {};
|
|
104
104
|
const scanned = scanRouter(route);
|
|
105
|
-
const paramsRegex = /:[^/]+/g;
|
|
106
105
|
scanned.forEach((route) => {
|
|
107
106
|
const fullPath = `/${routerName}${(0, parser_1.expressToSwagger)(route.path)}`;
|
|
108
107
|
routerDetails[fullPath] = {};
|
|
@@ -112,6 +111,16 @@ function routeAnalyzer(route, routerName) {
|
|
|
112
111
|
description: "Public route",
|
|
113
112
|
};
|
|
114
113
|
const validation = detail.middlewares.find((mw) => mw.handle?.__validationSchema)?.handle.__validationSchema;
|
|
114
|
+
const pathParams = [...fullPath.matchAll(/{([^}]+)}/g)].map((m) => m[1]);
|
|
115
|
+
if (pathParams.length) {
|
|
116
|
+
doc.parameters = pathParams.map((name) => ({
|
|
117
|
+
name,
|
|
118
|
+
in: "path",
|
|
119
|
+
required: validation?.params?.fields?.[name]?.spec?.optional == false ||
|
|
120
|
+
!new RegExp(`\\{[^\\}]*${name}[^\\}]*\\}`).test(route.path),
|
|
121
|
+
schema: { type: "string" },
|
|
122
|
+
}));
|
|
123
|
+
}
|
|
115
124
|
// If body exists
|
|
116
125
|
if (METHODS_WITH_BODY.includes(method)) {
|
|
117
126
|
if (validation?.body) {
|