OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.23k stars 6.43k forks source link

[REQ] [dart-dio] Further improvements to polymorphism support #13372

Open ahmednfwela opened 1 year ago

ahmednfwela commented 1 year ago

I made this issue to track what improvements can be introduced to the newly added polymorphism support for dart-dio https://github.com/OpenAPITools/openapi-generator/pull/12295 Suggestions and help are welcome !

banool commented 1 year ago

I would love for the generator to generate code that adds OneOf support in a type-checkable way. Currently using the OneOf stuff is quite hard to get right and the only way you can iterate is at runtime. For example, if you have a struct my MyOneOfStruct and it has a oneof field that expects A or B, you can pass in C and it will not complain at type check time, but fail at runtime. This makes it a real nightmare to know what to use.

In a similar vein, I'd love if the generatated code hid the types that you shouldn't need to use as an end user, such as the abstract classes, the *AllOf types, etc. These also make it super confusing what you're meant to use (not to mention all the $, $$, _$, etc. classes.

ahmednfwela commented 1 year ago

to add oneOf type check support, you would need the language to have union types https://github.com/dart-lang/language/issues/1222

ahmednfwela commented 1 year ago

the abstract classes are intended to be used by the end user

the QoL function I am suggesting is to make the user not need the $ classes