c2-http 1.0.49 → 1.0.50

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.
@@ -74,23 +74,21 @@ function OpenApi(target) {
74
74
  return class extends target {
75
75
  constructor() {
76
76
  super(); // Chama o construtor da classe original
77
- // const controller = target as unknown as Controller;
78
77
  const paths = {};
79
- // console.log(target)
80
- this.routers.stack.forEach((route) => {
81
- if (route.route && route.route.path) {
82
- const methodsUsed = this.getMethodsUsed2(route.route.methods);
83
- const methods = {};
84
- methodsUsed.forEach((method) => {
85
- methods[method] = {
86
- tags: [target.name]
87
- };
88
- });
89
- paths[route.route.path] = {
90
- ...paths[route.route.path],
91
- ...methods
92
- };
93
- }
78
+ this.routesControlled.forEach((route) => {
79
+ const methods = {};
80
+ methods[route.method] = {
81
+ tags: [target.name],
82
+ security: [
83
+ {
84
+ OAuth2: route.middlewaresRoles.roles
85
+ }
86
+ ]
87
+ };
88
+ paths[route.uri] = {
89
+ ...paths[route.uri],
90
+ ...methods
91
+ };
94
92
  });
95
93
  global.OPEN_API_DOC = {
96
94
  ...global.OPEN_API_DOC,
@@ -100,15 +98,6 @@ function OpenApi(target) {
100
98
  }
101
99
  };
102
100
  }
103
- getMethodsUsed2(obj) {
104
- const trueProperties = [];
105
- for (const key in obj) {
106
- if (obj[key] === true) {
107
- trueProperties.push(key);
108
- }
109
- }
110
- return trueProperties;
111
- }
112
101
  };
113
102
  }
114
103
  exports.OpenApi = OpenApi;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-http",
3
- "version": "1.0.49",
3
+ "version": "1.0.50",
4
4
  "description": "Biblioteca Typescript para API NodeJS",
5
5
  "repository": "https://cabralsilva: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@github.com/cabralsilva/c2-http.git",
6
6
  "author": "Daniel Cabral <cabralconsultoriaemsoftware@gmail.com>",