Same object referenced in multiple `oneOf` generates repeat discriminators
aherrmann13 opened this issue · 1 comments
I will try to build a minimal repro if needed but for now ill take an exerpt from my generated model. I have several objects that are referenced in a oneOf
property with the same discriminator. The template generated by @openapi-generator-plus/typescript-fetch-node-client-generator
will repeat this property multiple times.
e.g.
export interface InboxAssessment {
/**
* Value for discriminator in Api.Assessment.Section
*/
tag: Api.InboxAssessment.TagEnum.InboxAssessment;
/**
* Value for discriminator in Api.FacilitatorQuestions.Question
*/
tag: Api.InboxAssessment.TagEnum.InboxAssessment;
/**
* Value for discriminator in Api.AssessorQuestions.Question
*/
tag: Api.InboxAssessment.TagEnum.InboxAssessment;
sectionId: string;
rank: string;
orgchart: Api.Attachment;
items: Api.InboxAssessment.Item[];
}
I would like to ignore the discriminator all together and include it in the object def instead of going through the 'parent' object. Ideally the parent is specifying a discriminated union but each containing object is unaware of the 'parent' contexts that it is used in.
My questions are
- is this a bug in openapi-generator-plus?
- is there a simple way to remove the discriminator specific logic in template overrides and just add the prop as specified in the model (in this case,
InboxAssessment
) - for my own understanding (and so I can submit a pull request if this behavior is indeed buggy) what is the scenario where we would want to loop through the discriminators?
@aherrmann13 I have come across this myself now... I think this is a problem in the generated code... but it's a little difficult to solve in some cases. Have worked out an approach for this?