[dart][dart-dio] Add type information to oneOf and anyOf#20788
[dart][dart-dio] Add type information to oneOf and anyOf#20788fa0311 wants to merge 8 commits intoOpenAPITools:masterfrom
Conversation
|
Unfortunately, the dart-dio generator seems to lack sufficient tests, so it's unclear whether it works correctly in all cases. |
| typeIndex: oneOf.typeIndex, | ||
| ); | ||
| } | ||
| throw ArgumentError('Invalid number of types: ${oneOf.types.length}'); |
There was a problem hiding this comment.
We can maintain backward compatibility, but a simple replacement won't work.
If we simply return OneOfDynamic, it will fail when casting to OneOfx (OneOf{{oneOf.size}}), resulting in an error.
A slightly more involved approach would be to introduce a flag for cases with seven or more oneof values—if set to true, it would use OneOfDynamic.
There was a problem hiding this comment.
To be honest, I never really liked the idea of fitting infinitely large oneof/anyof cases into a single variable
The approach I followed here #18970 is much cleaner, and is similar to what protobuf does
|
Any updates? |
|
There are no updates to this. |
We will stop using OneOfDynamic and switch to OneOfx.
This will improve type safety.
PR checklist
Commit all changed files.
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/configs/java*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master(upcoming7.x.0minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)@jaumard (2018/09) @josh-burton (2019/12) @amondnet (2019/12) @sbu-WBT (2020/12) @kuhnroyal (2020/12) @agilob (2020/12) @ahmednfwela (2021/08)