OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
[ ] [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
When using the dart-dio generator to generate an API with an specs file, which uses multilayered classes with a discriminator at the lowest layer with an discriminator, the generated code tries to map all the values in the middle layer class to all of the subclasses of the lowest layer class.
e.g. classes animal, bird, reptile, turtle, crocodile
The generator runs without an error but there are issues inside of the generated code.
The discriminator mapping inside of the animal class is working fine but the one at reptile uses the same as the one at the animal. This creates a bird and then return it as a bird. This is not allowed in this place because bird is not a subtype of reptile. Since this is an compile error, created by parts of code, which will never be executed, any app using the library is unable is unable to be started.
Bug Report Checklist
Description
When using the dart-dio generator to generate an API with an specs file, which uses multilayered classes with a discriminator at the lowest layer with an discriminator, the generated code tries to map all the values in the middle layer class to all of the subclasses of the lowest layer class.
e.g. classes animal, bird, reptile, turtle, crocodile The generator runs without an error but there are issues inside of the generated code. The discriminator mapping inside of the animal class is working fine but the one at reptile uses the same as the one at the animal. This creates a bird and then return it as a bird. This is not allowed in this place because bird is not a subtype of reptile. Since this is an compile error, created by parts of code, which will never be executed, any app using the library is unable is unable to be started.
openapi-generator version
6.5.0, 6.6.0
OpenAPI declaration file content or url
https://gist.github.com/felixmede/058272bdad39fa14ee30f03e65dbd1df
Generation Details
openapi-generator generate -g dart-dio -i openAPI.json -o test
Steps to reproduce
Related issues/PRs
https://github.com/OpenAPITools/openapi-generator/issues/15386
Suggest a fix
Filter discriminators of subclass to only contain those classes, which are implementing this subclass