Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 of 5 tasks
ahmednfwela opened this issue Sep 7, 2022 · 3 comments
Open
1 of 5 tasks

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

ahmednfwela opened this issue Sep 7, 2022 · 3 comments

Comments

@ahmednfwela
Copy link
Contributor

ahmednfwela commented Sep 7, 2022

I made this issue to track what improvements can be introduced to the newly added polymorphism support for dart-dio #12295
Suggestions and help are welcome !

  • Merge all test schemas into one test schema for better maintainability
    • 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
    • should be merged with: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
    • into a new test schema specific for dart
  • Add polymorphism support to json_serializable
  • Add a new QoL method inside generated classes called createConcreteBuilder for built_value serializer
    • so for example if you have class Apple, the signature would be:
      static AppleBuilder createConcreteBuilder() => AppleBuilder();
    • if you have class Fruit which class Apple inherits from, it would have the signature:
      static $FruitBuilder createConcreteBuilder() => $FruitBuilder();
  • Implement MonoRepo structure for https://github.com/Bdaya-Dev/dart-oneof and write CD to auto deploy the package to pub.dev on each new release
  • Auto assign discriminator type on serialization based on type (PR [dart-dio] Fix non legacy discriminator behavior #14291)
    @kuhnroyal @agilob @jaumard @josh-burton @amondnet @sbu-WBT @banool
@banool
Copy link

banool commented Sep 7, 2022

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
Copy link
Contributor Author

ahmednfwela commented Sep 7, 2022

to add oneOf type check support, you would need the language to have union types dart-lang/language#1222

@ahmednfwela
Copy link
Contributor Author

ahmednfwela commented Sep 7, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants