@adaptivestone/framework 3.4.0 → 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 +9 -0
- package/commands/GetOpenApiJson.js +32 -6
- package/modules/AbstractController.js +5 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
### 3.4.2
|
|
2
|
+
|
|
3
|
+
[UPDATE] updated deps
|
|
4
|
+
[FIX] fix documentation generation
|
|
5
|
+
|
|
6
|
+
### 3.4.1
|
|
7
|
+
|
|
8
|
+
[FIX] fix documentation generation
|
|
9
|
+
|
|
1
10
|
### 3.4.0
|
|
2
11
|
|
|
3
12
|
[NEW] now we pass 'req' to validation and casting as a second parameter. This done mostly for custom validators
|
|
@@ -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]];
|
|
@@ -91,14 +92,18 @@ class GetOpenApiJson extends AbstractCommand {
|
|
|
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) {
|
|
97
100
|
for (const authParam of middleware.authParams) {
|
|
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;
|
|
@@ -148,10 +152,18 @@ class GetOpenApiJson extends AbstractCommand {
|
|
|
148
152
|
openApi.paths[routeName] = {};
|
|
149
153
|
}
|
|
150
154
|
|
|
151
|
-
const methodName = route[Object.keys(route)[0]].method.toLowerCase();
|
|
152
|
-
const routeTitle = route[Object.keys(route)[0]].name;
|
|
153
155
|
const routeDescription =
|
|
154
156
|
route[Object.keys(route)[0]]?.description || 'empty description';
|
|
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}`;
|
|
164
|
+
const methodName = route[Object.keys(route)[0]].method.toLowerCase();
|
|
165
|
+
const routeTitle = route[Object.keys(route)[0]].name;
|
|
166
|
+
|
|
155
167
|
const routeFields = route[Object.keys(route)[0]].fields;
|
|
156
168
|
|
|
157
169
|
if (!openApi.paths[routeName][methodName]) {
|
|
@@ -165,7 +177,8 @@ class GetOpenApiJson extends AbstractCommand {
|
|
|
165
177
|
);
|
|
166
178
|
|
|
167
179
|
openApi.paths[routeName][methodName].summary = routeTitle;
|
|
168
|
-
openApi.paths[routeName][methodName].description =
|
|
180
|
+
openApi.paths[routeName][methodName].description =
|
|
181
|
+
routeDescriptionWithPermissions;
|
|
169
182
|
openApi.paths[routeName][methodName].parameters = [];
|
|
170
183
|
openApi.paths[routeName][methodName].security = securitySchemaNames;
|
|
171
184
|
|
|
@@ -229,6 +242,19 @@ class GetOpenApiJson extends AbstractCommand {
|
|
|
229
242
|
type: field.innerType,
|
|
230
243
|
};
|
|
231
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
|
+
}
|
|
232
258
|
}
|
|
233
259
|
}
|
|
234
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}*` ||
|