Version: @anatine/zod-openapi: 2.2.7
z.object({
messages: z.string().array().default([]),
})
The infered type is
messages: string[] // Mandatory field
However, OpenAPI contract rendered as optional field
{
"type": [
"object"
],
"properties": {
"messages": {
"default": [],
"type": [
"array"
],
"items": {
"type": [
"string"
]
}
}
},
"required": []
}
This doesn't make sense, the field should be required in openapi contract.