Field with optional zod type but required on swagger

58 views Asked by At

I have this

const FinesListPaginatedQuerySchema = z.object({ dateFrom: z.coerce.date().optional()})
export class FinesListPaginatedRequestQueryDto extends createZodDto(FinesListPaginatedQuerySchema) {}

and my controller is

 public findFines(@Query() query: FinesListPaginatedRequestQueryDto))

I want that my field will be optional but on swagger I see only required

UPD

There is interesting moment. When I have got two fields on my FinesListPaginatedQuerySchema (optional and required) its ok. But when its optional and optional, my fields become required. It happens on const reflectedParam = Reflect.getMetadata(constants_1.DECORATORS.API_MODEL_PROPERTIES, prototype, key) returns params without required option(I don't know why if I have only optional parameters it equal undefined)

0

There are 0 answers