Repository navigation
Closed
oazapfts/oazapfts
#671Labels
RTKQ-CodegenIssues related to the @rtk-query/codegen-openapi package.
Description
In our OpenAPI specification, we have a type Allowance that can be either a EngineeringAllowance or StandardAllowance.
we use the property allowance_type as discriminator.
Allowance:
oneOf:
- $ref: "#/components/schemas/EngineeringAllowance"
- $ref: "#/components/schemas/StandardAllowance"
discriminator:
propertyName: allowance_typeeach allowance type correspond to one allowance_type string, as given by the enum
StandardAllowance:
properties:
allowance_type:
type: string
enum: ["standard"]The types generated by rtk-query/codegen-openapi isn’t correct,
the type Allowance is empty. The discrimated union never match the given patterns allowance_type: 'EngineeringAllowance'; or allowance_type: 'StandardAllowance'; as it’s the wrong strings.
the strings do not match with the value given in the openAPI definition, it simply uses the name of the Schema.
It should use the provided allowance_type strings given in the allowance_type enum for each schema.
export type EngineeringAllowance = {
allowance_type?: 'engineering';
distribution?: 'MARECO' | 'LINEAR';
capacity_speed_limit?: number;
} & RangeAllowance;
export type StandardAllowance = {
allowance_type?: 'standard';
default_value?: AllowanceValue;
ranges?: RangeAllowance[];
distribution?: 'MARECO' | 'LINEAR';
capacity_speed_limit?: number;
};
export type Allowance =
| ({
allowance_type: 'EngineeringAllowance';
} & EngineeringAllowance)
| ({
allowance_type: 'StandardAllowance';
} & StandardAllowance); Allowance:
oneOf:
- $ref: "#/components/schemas/EngineeringAllowance"
- $ref: "#/components/schemas/StandardAllowance"
discriminator:
propertyName: allowance_type
StandardAllowance:
properties:
allowance_type:
type: string
enum: ["standard"]
default_value:
$ref: "#/components/schemas/AllowanceValue"
ranges:
type: array
items:
$ref: "#/components/schemas/RangeAllowance"
distribution:
type: string
enum: ["MARECO", "LINEAR"]
capacity_speed_limit:
type: number
format: double
EngineeringAllowance:
allOf:
- type: object
properties:
allowance_type:
type: string
enum: ["engineering"]
distribution:
type: string
enum: ["MARECO", "LINEAR"]
capacity_speed_limit:
type: number
format: double
- $ref: "#/components/schemas/RangeAllowance"Reacted by jens270996, Evan Gillogley, Yuriy, Florian Amsallem , mdvanes, Vladislav Stroev, Tywen Kelly, Ilya Gavrilov, rewweRrr, Dee Roberts and 9 more
Metadata
Metadata
Assignees
Labels
RTKQ-CodegenIssues related to the @rtk-query/codegen-openapi package.
Activity
[-]Openapi-codegen doesn’t handle discriminated this union properly[/-][+]Openapi-codegen doesn’t handle discriminated union properly[/+]henkkasoft commentedon Nov 25, 2024
Hope that the fix for this issue is merged and released soon
gateway: remove LoginResponse discriminator
gateway: remove LoginResponse discriminator
gateway: remove LoginResponse discriminator
mrpelz commentedon Dec 5, 2025
Any timeline for incorporating the changes from oazapfts/oazapfts#671 into a
@rtk-query/codegen-openapirelease, i.e. upgrading@oazapfts/runtimeto v1.0.4?markerikson commentedon Dec 5, 2025
@mrpelz : our current dep is
"@oazapfts/runtime": "^1.0.3",, so there shouldn't be any action required on our end for you to make use of that - it should get installed when you use the codegen as the latest version.Add test for #3369
Add test for #3369 (#5154)
markerikson commentedon Dec 7, 2025
Okay, did some more investigation.
Looks like:
@oazapfts/runtimedep I mentioned is just part of our own dev depsoazapftsitself and came out in v6.3.0oazapftsdep to 6.3.0 a while ago