moahmedwafy commited on
Commit
7a8d84c
·
1 Parent(s): ccb54a8

feat: get automatic params

Browse files
Files changed (1) hide show
  1. src/lib/swagger/swagger.ts +15 -0
src/lib/swagger/swagger.ts CHANGED
@@ -121,6 +121,8 @@ class SwaggerRegistry {
121
 
122
  controllerData.routes.forEach((route) => {
123
  route.path = `/api/v1${controllerData.prefix}${route.path}`;
 
 
124
 
125
  if (!paths[route.path]) {
126
  paths[route.path] = {};
@@ -135,6 +137,19 @@ class SwaggerRegistry {
135
  tags: [...(controllerData.tags || []), ...(route.tags || [])],
136
  summary: route.summary,
137
  description: route.description,
 
 
 
 
 
 
 
 
 
 
 
 
 
138
  responses: {
139
  200: {
140
  description: "Success",
 
121
 
122
  controllerData.routes.forEach((route) => {
123
  route.path = `/api/v1${controllerData.prefix}${route.path}`;
124
+ const params = route.path.match(/:(\w+)/g);
125
+ console.log(route.path, params);
126
 
127
  if (!paths[route.path]) {
128
  paths[route.path] = {};
 
137
  tags: [...(controllerData.tags || []), ...(route.tags || [])],
138
  summary: route.summary,
139
  description: route.description,
140
+ parameters:
141
+ (params &&
142
+ params.map((param) => {
143
+ return {
144
+ name: param.replace(":", ""),
145
+ in: "path",
146
+ required: true,
147
+ schema: {
148
+ type: "string",
149
+ },
150
+ };
151
+ })) ||
152
+ [],
153
  responses: {
154
  200: {
155
  description: "Success",