Skip to content
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

Same object referenced in multiple oneOf generates repeat discriminators #52

Open
aherrmann13 opened this issue Dec 5, 2023 · 1 comment

Comments

@aherrmann13
Copy link

aherrmann13 commented Dec 5, 2023

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

  1. is this a bug in openapi-generator-plus?
  2. 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)
  3. 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?
@karlvr
Copy link
Owner

karlvr commented Apr 26, 2024

@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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants