File tree Expand file tree Collapse file tree 4 files changed +21
-9
lines changed Expand file tree Collapse file tree 4 files changed +21
-9
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @danet/swagger" ,
3
- "version" : " 2.2 .0" ,
3
+ "version" : " 2.3 .0" ,
4
4
"exports" : {
5
5
"." :" ./mod.ts" ,
6
6
"./decorators" : " ./decorators.ts"
Original file line number Diff line number Diff line change @@ -133,7 +133,7 @@ class HelloController {
133
133
@Controller ( 'zod' )
134
134
class ZodController {
135
135
@Post ( )
136
- posZodSomething ( @ZodBody ( ZodTodo ) todo : ZodTodo ) : number {
136
+ posZodSomething ( @ZodBody ( ZodTodo ) todo : ZodTodo ) {
137
137
return 1 ;
138
138
}
139
139
@@ -156,10 +156,9 @@ class MyController {
156
156
}
157
157
158
158
@ApiOAuth2 ( [ 'my-permission:all' ] )
159
- @ReturnedType ( Todo )
160
159
@Post ( )
161
- postSomething ( @Body ( ) todo : Todo ) : number {
162
- return 1 ;
160
+ postSomething ( @Body ( ) todo : Todo ) : Todo {
161
+ return new Todo ( ) ;
163
162
}
164
163
165
164
@ApiCookieAuth ( )
@@ -171,7 +170,7 @@ class MyController {
171
170
172
171
@BodyType ( Todo )
173
172
@Put ( 'somethingagain' )
174
- putSomething ( ) : Todo {
173
+ putSomething ( ) {
175
174
return new Todo ( ) ;
176
175
}
177
176
}
Original file line number Diff line number Diff line change @@ -259,6 +259,19 @@ export class MethodDefiner {
259
259
this . Controller . prototype ,
260
260
this . methodName ,
261
261
) ;
262
+ if ( ! returnedValue ) {
263
+ const returnedType = MetadataHelper . getMetadata < Constructor > (
264
+ 'design:returntype' ,
265
+ this . Controller . prototype ,
266
+ this . methodName ,
267
+ ) ;
268
+ if ( returnedType ) {
269
+ returnedValue = {
270
+ returnedType,
271
+ isArray : false ,
272
+ } ;
273
+ }
274
+ }
262
275
if ( returnedValue ) {
263
276
if ( isPrimitive ( returnedValue . returnedType . name . toLowerCase ( ) ) ) {
264
277
if ( returnedValue . isArray ) {
@@ -298,7 +311,6 @@ export class MethodDefiner {
298
311
this . Controller . prototype ,
299
312
this . methodName
300
313
) ;
301
- console . log ( 'returnedSchema' , returnedSchema ) ;
302
314
if ( returnedSchema ) {
303
315
const openApiSchema = this . generateZodSchema ( returnedSchema . returnedSchema ) ;
304
316
if ( returnedSchema . isArray ) {
@@ -313,6 +325,7 @@ export class MethodDefiner {
313
325
'$ref' : `#/components/schemas/${ openApiSchema . title } ` ,
314
326
} ) . setDescription ( '' ) . get ( ) ;
315
327
}
328
+ return ;
316
329
}
317
330
318
331
return null ;
You can’t perform that action at this time.
0 commit comments