-
-
Notifications
You must be signed in to change notification settings - Fork 542
Description
Consider the following bit that's part of a swagger.yml schema:
Order:
type: object
oneOf:
- $ref: '#/components/schemas/OrderByQuantity'
- $ref: '#/components/schemas/OrderByValue'
discriminator:
propertyName: type
mapping:
quantity: '#/components/schemas/OrderByQuantity'
value: '#/components/schemas/OrderByValue'
required:
- type
properties:
type:
type: string
description: Identifies whether the order has been placed by quantity (kg CO2) or value (monetary amount)
example: quantity
enum:
- quantity
- value
When I use openapi-typescript-codegen to generate the TypeScript type I get:
export type Order = (OrderByQuantity | OrderByValue | { type: 'quantity' | 'value', });
This seems incorrect - it seems like {type: 'quantity' | 'value'} should extend the type instead:
export type Order = (OrderByQuantity | OrderByValue * { type: 'quantity' | 'value', });
For comparison, here's what i get when i use https://www.npmjs.com/package/openapi-typescript -->
readonly Order: ( | components["schemas"]["OrderByQuantity"] | components["schemas"]["OrderByValue"] ) & { /** Identifies whether the order has been placed by quantity (kg CO2) or value (monetary amount) */ readonly type: "quantity" | "value"; } & { readonly [key: string]: any };