-
Notifications
You must be signed in to change notification settings - Fork 96
Open
Description
Description
I have the following scenario:
const Brand = z.enum(['Ford', 'Toyota', 'Tesla']).openapi('Brand');
const Car = z
.object({
brand: Brand.nullable(),
model: z.string(),
})
.openapi('Car');Expected result
I expected the property Car.brand to be a nullable Brand
components:
schemas:
Brand:
type: string
enum:
- Ford
- Toyota
- Tesla
Car:
type: object
properties:
brand:
oneOf:
- type: 'null'
- $ref: '#/components/schemas/Brand'
model:
type: stringActual result
The spec generated declares Brand as nullable, instead of making the property Car.brand nullable
components:
schemas:
Brand:
type:
- string
- 'null'
enum:
- Ford
- Toyota
- Tesla
Car:
type: object
properties:
brand:
$ref: '#/components/schemas/Brand'
model:
type: stringMore info
I understand the rationale behind the way this was generated. The problem is that Brand could be reusable, and in some places it might not be nullable. Is there a workaround this?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels