Enums in Kubb #1919
-
|
Hi, I'm not entirely sure if this is a bug or expected behavior, but in my openapi.json, there are properties that refer to a specific Enum, and the list of possible values is limited. "auditType": {
"$ref": "#/components/schemas/AuditEventType",
"enum": [
"OFFER"
]
}When I generate types, Kubb for some reason uses export const offerBrokerDTO = z.object({
auditType: z.optional(z.lazy(() => auditEventType)),
});Although I would expect kubb to use only the enum field if it exists. export const offerBrokerDTO = z.object({
auditType: z.optional(z.enum(["OFFER"])),
});Due to the permissible overlap of types, this should not be an issue, or am I missing something? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
You can’t mix $ref and enum at the same level in OpenAPI 3.x (or JSON Schema draft-04/05/07, which OAS 3.x is based on). The $ref keyword replaces the entire schema at that location. Example on how this should be done: |
Beta Was this translation helpful? Give feedback.
@skoropadas
You can’t mix $ref and enum at the same level in OpenAPI 3.x (or JSON Schema draft-04/05/07, which OAS 3.x is based on).
The $ref keyword replaces the entire schema at that location.
You cannot add other siblings like enum, type, description, etc.
Example on how this should be done: