Skip to content

Inheritance in openApi code generation incorrect. #2002

@AlexBrad1ey

Description

@AlexBrad1ey

Swagger Inheritance & Polymorphism is not generating correctly from the OpenApi definition. this is directly related to #1940. But i am recording this as a seperate issue because it references a different case but is most probably a related error in the code.

I have striped down the situation as to not clutter the issue.
When a openApi schema has an Entity base type and a subtype called Project, and is defined simply as Project -> allOf -> Entity with no descriminators or anything just a simple inheritance the Project entity is not correctly generated.

RTK Generator produces the following type output:

export type Entity= {
  id?: string | null;
  name?: string | null;
  description?: string | null;
  status?: string | null;
};
export type Project = Entity

This is incorrect and seems to have 2 mistakes:

  1. all additional properties on a subtype are lost due to the Project = Entity.
  2. the missing properties are caused because the code gen creates types not interfaces which cannot be extended.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions