| 128 | |
| 129 | @Route('ComplexType') |
| 130 | export class ComplexTypeController { |
| 131 | /** |
| 132 | * Test @Body with z.infer type (complex types should use @Body, not @Queries) |
| 133 | */ |
| 134 | @Post('ZodUserBody') |
| 135 | public async postZodUserBody(@Body() body: z.infer<typeof UserSchema>): Promise<z.infer<typeof UserSchema>> { |
| 136 | return body; |
| 137 | } |
| 138 | |
| 139 | /** |
| 140 | * Test @Body with complex z.infer type |
| 141 | */ |
| 142 | @Post('ZodProductBody') |
| 143 | public async postZodProductBody(@Body() body: z.infer<typeof ProductSchema>): Promise<z.infer<typeof ProductSchema>> { |
| 144 | return body; |
| 145 | } |
| 146 | |
| 147 | /** |
| 148 | * Test @Body with nested z.infer type |
| 149 | */ |
| 150 | @Post('ZodOrderBody') |
| 151 | public async postZodOrderBody(@Body() body: z.infer<typeof OrderSchema>): Promise<z.infer<typeof OrderSchema>> { |
| 152 | return body; |
| 153 | } |
| 154 | |
| 155 | /** |
| 156 | * Test @Body with simple generic type using primitive types |
| 157 | */ |
| 158 | @Post('SimpleGenericBody') |
| 159 | public async postSimpleGenericBody(@Body() body: GenericWrapper<string>): Promise<GenericWrapper<string>> { |
| 160 | return body; |
| 161 | } |
| 162 | |
| 163 | /** |
| 164 | * Test @Body with generic type using interface types |
| 165 | */ |
| 166 | @Post('InterfaceGenericBody') |
| 167 | public async postInterfaceGenericBody(@Body() body: GenericWrapper<Task>): Promise<GenericWrapper<Task>> { |
| 168 | return body; |
| 169 | } |
| 170 | |
| 171 | /** |
| 172 | * Test @Body with simple interface type |
| 173 | */ |
| 174 | @Post('SimpleInterfaceBody') |
| 175 | public async postSimpleInterfaceBody(@Body() body: Task): Promise<Task> { |
| 176 | return body; |
| 177 | } |
| 178 | |
| 179 | /** |
| 180 | * Test @Body with union types |
| 181 | */ |
| 182 | @Post('UnionTypeBody') |
| 183 | public async postUnionTypeBody(@Body() body: Task): Promise<Task> { |
| 184 | return body; |
| 185 | } |
| 186 | |
| 187 | /** |