[Dart] Set type of OneOf to dynamic#6914
[Dart] Set type of OneOf to dynamic#6914sbu-WBT wants to merge 3 commits intoOpenAPITools:masterfrom
Conversation
|
@sbu-WBT thanks for the PR. Can you please PM me via Slack to discuss on oneOf support in Dart? |
|
maybe this can be done using sum types from this package but in that case using the dart code would require another codegen step via the dart build system. |
|
I vote for landing this. Waiting for sum types or unions to land will take years. |
|
The problem is that oneOf is used now for nullable objects. in spec 3.1 there would be 'null' keyword for such cases, but even then this case is not of the list. So we at least should handle these cases with care. This is not Oh, I've should read the commit before. You already handle this case. |
# Conflicts: # modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartClientCodegen.java
|
Any update on this? oneOf is causing troubles for our project |
|
@jgoyvaerts would you be interested in testing and updating this PR against your project? |
|
I tested this branch locally, while it does get rid of the generated properties OneOfType which cause compile errors and replaces these with dynamic? , it still isn't completely correct in handling the case described by @yfer , where those dynamic? should actually be generated as nullable types, so Type?. I'll see if I can write a fix for this case |
|
Well, NNBD is not implemented at all in the Dart generator I believe. |
OneOf is currently not supported by dart. Thus it makes no sense to generate code with it. So I replaced it with a
dynamictype. We loose with this case the typing, but the code does compile and should work with all primitives. I'm unsure if serialization with generated data classes will work.So it fixes #3884.
PR checklist
./bin/generate-samples.shto update all Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example./bin/generate-samples.sh bin/config/java*. For Windows users, please run the script in Git BASH.master@ircecho (2017/07) @swipesight (2018/09) @jaumard (2018/09) @athornz (2019/12) @amondnet (2019/12)