Open ahmednfwela opened 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.
to add oneOf type check support, you would need the language to have union types https://github.com/dart-lang/language/issues/1222
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
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 !modules/openapi-generator/src/test/resources/3_0/oneof_polymorphism_and_inheritance.yaml
modules/openapi-generator/src/test/resources/3_0/oneOf_primitive.yaml
modules/openapi-generator/src/test/resources/3_0/oneOf.yaml
modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
json_serializable
createConcreteBuilder
forbuilt_value
serializerApple
, the signature would be:static AppleBuilder createConcreteBuilder() => AppleBuilder();
Fruit
which classApple
inherits from, it would have the signature:static $FruitBuilder createConcreteBuilder() => $FruitBuilder();