@carno.js/swagger 0.2.9 → 0.2.10
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/dist/swagger.service.js +10 -10
- package/package.json +2 -2
package/dist/swagger.service.js
CHANGED
|
@@ -173,34 +173,34 @@ window.onload = () => {
|
|
|
173
173
|
/**
|
|
174
174
|
* Search controllers classes
|
|
175
175
|
*/
|
|
176
|
-
//
|
|
176
|
+
// Walk through all source files
|
|
177
177
|
for (const sourceFile of sourceFiles) {
|
|
178
|
-
//
|
|
178
|
+
// Read all classes from the source file
|
|
179
179
|
const classes = sourceFile.getClasses();
|
|
180
|
-
//
|
|
180
|
+
// Walk through each class
|
|
181
181
|
for (const cls of classes) {
|
|
182
182
|
// Verifique se a classe tem um decorador 'Controller'
|
|
183
183
|
const controllerDecorator = cls.getDecorator('Controller');
|
|
184
184
|
if (controllerDecorator) {
|
|
185
|
-
//
|
|
185
|
+
// Read the controller prefix from the 'Controller' decorator
|
|
186
186
|
const controllerPrefix = controllerDecorator.getArguments()[0]?.getText();
|
|
187
|
-
//
|
|
187
|
+
// Walk through every method in the class
|
|
188
188
|
for (const method of cls.getMethods()) {
|
|
189
|
-
//
|
|
189
|
+
// Check whether the method has an HTTP decorator
|
|
190
190
|
const httpDecorator = method.getDecorators().find(decorator => ['Get', 'Post', 'Put', 'Delete'].includes(decorator.getName()));
|
|
191
191
|
if (httpDecorator) {
|
|
192
|
-
//
|
|
192
|
+
// Read the route path from the HTTP decorator
|
|
193
193
|
let routePath = httpDecorator.getArguments()[0]?.getText();
|
|
194
194
|
routePath = controllerPrefix + routePath;
|
|
195
|
-
//
|
|
195
|
+
// Read the HTTP method from the decorator name
|
|
196
196
|
const httpMethod = httpDecorator.getName().toLowerCase();
|
|
197
|
-
//
|
|
197
|
+
// Add the route to the Swagger object
|
|
198
198
|
if (!swaggerObject.paths[routePath]) {
|
|
199
199
|
swaggerObject.paths[routePath] = {};
|
|
200
200
|
}
|
|
201
201
|
swaggerObject.paths[routePath][httpMethod] = {
|
|
202
202
|
summary: method.getJsDocs().map(jsDoc => jsDoc.getComment()).join('\n'),
|
|
203
|
-
//
|
|
203
|
+
// Add more properties as needed
|
|
204
204
|
};
|
|
205
205
|
}
|
|
206
206
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carno.js/swagger",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.10",
|
|
4
4
|
"description": "Generate automatically swagger.json from your carno.js project",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"carno.js",
|
|
43
43
|
"swagger"
|
|
44
44
|
],
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "5c765c2c9172bec7f509ca2513f6c10472ec89eb"
|
|
46
46
|
}
|