Skip to content

Same object referenced in multiple oneOf generates repeat discriminators #52

@aherrmann13

Description

@aherrmann13

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions