@adaptivestone/framework 3.4.1 → 3.4.2
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/CHANGELOG.md +5 -0
- package/commands/GetOpenApiJson.js +27 -4
- package/modules/AbstractController.js +5 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -81,6 +81,7 @@ class GetOpenApiJson extends AbstractCommand {
|
|
|
81
81
|
|
|
82
82
|
openApi.paths = {};
|
|
83
83
|
|
|
84
|
+
const permissionWithRoutes = {};
|
|
84
85
|
for (const controller of baseDocumentation) {
|
|
85
86
|
for (const route of controller.routesInfo) {
|
|
86
87
|
const routeInfo = route[Object.keys(route)?.[0]];
|
|
@@ -90,7 +91,9 @@ class GetOpenApiJson extends AbstractCommand {
|
|
|
90
91
|
];
|
|
91
92
|
|
|
92
93
|
const securitySchemaNames = [];
|
|
93
|
-
|
|
94
|
+
|
|
95
|
+
permissionWithRoutes[Object.keys(route)?.[0]] = [];
|
|
96
|
+
|
|
94
97
|
if (middlewares?.length) {
|
|
95
98
|
for (const middleware of middlewares) {
|
|
96
99
|
if (middleware?.authParams?.length) {
|
|
@@ -98,7 +101,9 @@ class GetOpenApiJson extends AbstractCommand {
|
|
|
98
101
|
const { permissions, ...mainFields } = authParam;
|
|
99
102
|
const fullName = authParam.name;
|
|
100
103
|
if (permissions) {
|
|
101
|
-
|
|
104
|
+
permissionWithRoutes[Object.keys(route)?.[0]].push(
|
|
105
|
+
permissions,
|
|
106
|
+
);
|
|
102
107
|
}
|
|
103
108
|
|
|
104
109
|
if (!openApi.components.securitySchemes[fullName]) {
|
|
@@ -114,7 +119,6 @@ class GetOpenApiJson extends AbstractCommand {
|
|
|
114
119
|
}
|
|
115
120
|
|
|
116
121
|
let routeName = Object.keys(route)[0];
|
|
117
|
-
|
|
118
122
|
if (routeName === '/') {
|
|
119
123
|
// eslint-disable-next-line no-continue
|
|
120
124
|
continue;
|
|
@@ -150,7 +154,13 @@ class GetOpenApiJson extends AbstractCommand {
|
|
|
150
154
|
|
|
151
155
|
const routeDescription =
|
|
152
156
|
route[Object.keys(route)[0]]?.description || 'empty description';
|
|
153
|
-
const
|
|
157
|
+
const permissions =
|
|
158
|
+
permissionWithRoutes[Object.keys(route)[0]][
|
|
159
|
+
permissionWithRoutes[Object.keys(route)[0]].length - 1
|
|
160
|
+
];
|
|
161
|
+
const routeDescriptionWithPermissions = `${
|
|
162
|
+
permissions || ''
|
|
163
|
+
} ${routeDescription}`;
|
|
154
164
|
const methodName = route[Object.keys(route)[0]].method.toLowerCase();
|
|
155
165
|
const routeTitle = route[Object.keys(route)[0]].name;
|
|
156
166
|
|
|
@@ -232,6 +242,19 @@ class GetOpenApiJson extends AbstractCommand {
|
|
|
232
242
|
type: field.innerType,
|
|
233
243
|
};
|
|
234
244
|
}
|
|
245
|
+
|
|
246
|
+
if (field.type === 'lazy') {
|
|
247
|
+
groupBodyFields[field.name] = {
|
|
248
|
+
oneOf: [
|
|
249
|
+
{
|
|
250
|
+
type: 'object',
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
type: 'string',
|
|
254
|
+
},
|
|
255
|
+
],
|
|
256
|
+
};
|
|
257
|
+
}
|
|
235
258
|
}
|
|
236
259
|
}
|
|
237
260
|
|
|
@@ -364,13 +364,11 @@ class AbstractController extends Base {
|
|
|
364
364
|
.map((middleware) => {
|
|
365
365
|
const routeFullPath = route.fullPath.toUpperCase();
|
|
366
366
|
const middlewareFullPath = middleware.fullPath.toUpperCase();
|
|
367
|
-
const middlewareFullPathWithSliced = middleware.fullPath
|
|
368
|
-
.toUpperCase()
|
|
369
|
-
.slice(0, -1);
|
|
370
367
|
if (
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
368
|
+
route.method.toLowerCase() ===
|
|
369
|
+
middleware.method.toLowerCase() &&
|
|
370
|
+
(middlewareFullPath === routeFullPath ||
|
|
371
|
+
middlewareFullPath === `${routeFullPath}*`)
|
|
374
372
|
) {
|
|
375
373
|
return {
|
|
376
374
|
name: middleware.name,
|
|
@@ -390,6 +388,7 @@ class AbstractController extends Base {
|
|
|
390
388
|
const middlewareFullPathWithSliced = middleware.fullPath
|
|
391
389
|
.toUpperCase()
|
|
392
390
|
.slice(0, -1);
|
|
391
|
+
|
|
393
392
|
return (
|
|
394
393
|
middlewareFullPath === routeFullPath ||
|
|
395
394
|
middlewareFullPath === `${routeFullPath}*` ||
|