-
-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support discriminators #1121
Comments
@vitorcamachoo can you provide details where the current behavior of kubb is not as you expected? Ideally with a minimal schema that replicates the issue(s)? |
For the following schema: ---
openapi: 3.0.3
components:
schemas:
IssueEventParameters:
type: object
anyOf:
- '$ref': '#/components/schemas/IssueEventParametersAcceptAssignment'
- '$ref': '#/components/schemas/IssueEventParametersAddApprover'
- '$ref': '#/components/schemas/IssueEventParametersAddTeam'
discriminator:
propertyName: eventType
mapping:
accept_assignment: '#/components/schemas/IssueEventParametersAcceptAssignment'
add_approver: '#/components/schemas/IssueEventParametersAddApprover'
add_team: '#/components/schemas/IssueEventParametersAddTeam' With the current Kubb version, it is being generated the following code: import { IssueEventParametersAcceptAssignmentSchema } from './issueEventParametersAcceptAssignmentSchema';
import { IssueEventParametersAddApproverSchema } from './issueEventParametersAddApproverSchema';
import { IssueEventParametersAddTeamSchema } from './issueEventParametersAddTeamSchema';
export type IssueEventParametersSchema =
| IssueEventParametersAcceptAssignmentSchema
| IssueEventParametersAddApproverSchema
| IssueEventParametersAddTeamSchema; file: issueEventParametersAcceptAssignmentSchema
export type IssueEventParametersAcceptAssignmentSchema = {
/**
* @type object
*/
parameters: {
/**
* @type string | undefined, uuid
*/
issueAssignmentId?: string;
};
}; The expectation of this last piece of code should be the following (it is missing the eventType property): (generated by Orval)
import type { IssueEventParametersAcceptAssignmentSchemaEventType } from './issueEventParametersAcceptAssignmentSchemaEventType';
import type { IssueEventParametersAcceptAssignmentSchemaParameters } from './issueEventParametersAcceptAssignmentSchemaParameters';
export interface IssueEventParametersAcceptAssignmentSchema {
eventType: IssueEventParametersAcceptAssignmentSchemaEventType;
parameters: IssueEventParametersAcceptAssignmentSchemaParameters;
} |
@vitorcamachoo Can you provide my your swagger/openAPI(or a stripped down version) because I tried with the following example: https://gist.github.com/vrialland/7031316121cb8e025dfca9dccfc226b1 and that works just fine so not sure what we are missing or need to adapt. |
@helt @vitorcamachoo |
What is the problem this feature would solve?
Our API is using the discriminators feature from the open API and Kubb does not support that making a possible migration to this tool impossible.
Supporting discriminators would be really useful for the community.
https://swagger.io/docs/specification/data-models/inheritance-and-polymorphism/
External documents/projects?
No response
What is the feature you are proposing to solve the problem?
No response
What alternatives have you considered?
No response
The text was updated successfully, but these errors were encountered: