You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Have you provided a full/minimal spec to reproduce the issue?
Have you validated the input using an OpenAPI validator (example)?
What's the version of OpenAPI Generator used?
Have you search for related issues/PRs?
What's the actual output vs expected output?
Description
When a model uses allOf, where some of the referenced models do not have a discriminator (hence, do not denote any hierarchy), the target interface just gets all properties copied from the referenced models, no interface inheritance/extending involved.
However, the base interfaces are still imported into the file with the target model - despite being unused.
The fixes for linked axios and rxjs generators above change the approach for generating a target interface: instead of copying all properties from the source interfaces into the target one, the target type is simply defined as type intersection.
Perhaps we should consider doing the same for typescript-angular (and probably other typescript generators that emit each model in a separate file with imports).
Note that the above mentioned fixes apply the same approach both with or without discriminator, thus erasing the semantic difference between them (hierarchy vs composition)
The text was updated successfully, but these errors were encountered:
Bug Report Checklist
Description
When a model uses
allOf
, where some of the referenced models do not have a discriminator (hence, do not denote any hierarchy), the target interface just gets all properties copied from the referenced models, no interface inheritance/extending involved.However, the base interfaces are still imported into the file with the target model - despite being unused.
openapi-generator version
Latest
OpenAPI declaration file content or url
Command line used for generation
Steps to reproduce
model/responseOnePlus.ts
.It will looks like this:Both imports here are not used.
Related issues/PRs
Similar issues:
typescript-axios
: [BUG][typescript-axios] Unnecessary imports occurs when using nested model in allOf #4804typescript-rxjs
: [BUG][typescript-rxjs] Unnecessary imports occurs when using allOf #4629Suggest a fix
The fixes for linked axios and rxjs generators above change the approach for generating a target interface: instead of copying all properties from the source interfaces into the target one, the target type is simply defined as type intersection.
Perhaps we should consider doing the same for typescript-angular (and probably other typescript generators that emit each model in a separate file with imports).
Note that the above mentioned fixes apply the same approach both with or without
discriminator
, thus erasing the semantic difference between them (hierarchy vs composition)The text was updated successfully, but these errors were encountered: