I upgraded my openapi_generator to 4.10.0 which uses Dio 5.0. Since Dio 5.0 switched to using DioException and deprecated DioError the generated code now can throw two types of exceptions.
if the request itself fails it will now get DioException since that is what Dio 5.0 and above use
if the failure happens in the serialization flow the auto gen code is still using DioError
generate an openapi spec using the dart dio option, here is the command I use openapi-generator generate -i ./swagger.json -g dart-dio -o ./dartdio-codegen
look at any of the generated apis in dartdio-codegen/lib/src/api to see the use of the deprecated DioError class
Expected behavior
The use of DioError and DioErrorType for serialization errors should be switched to DioException and DioExceptionType
Logs
No response
Screenshots
No response
Platform
macOS
Library version
4.10.0
Flutter version
3.10.4
Flutter channel
stable
Additional context
flutter info
[✓] Flutter (Channel stable, 3.10.4, on macOS 13.1 22C65 darwin-arm64, locale en-US)
• Flutter version 3.10.4 on channel stable at /Users/bg/development/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 682aa387cf (3 weeks ago), 2023-06-05 18:04:56 -0500
• Engine revision 2a3401c9bb
• Dart version 3.0.3
• DevTools version 2.23.1
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
• Android SDK at /Users/bg/Library/Android/sdk
• Platform android-33, build-tools 33.0.1
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 14.0)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14A309
• CocoaPods version 1.11.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2022.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
[✓] VS Code (version 1.73.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension can be installed from:
🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[✓] Connected device (2 available)
• macOS (desktop) • macos • darwin-arm64 • macOS 13.1 22C65 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 114.0.5735.133
[✓] Network resources
• All expected network resources are available.
• No issues found!
Description of the bug
I upgraded my openapi_generator to 4.10.0 which uses Dio 5.0. Since Dio 5.0 switched to using DioException and deprecated DioError the generated code now can throw two types of exceptions.
DioException
since that is what Dio 5.0 and above useSteps to reproduce
openapi-generator generate -i ./swagger.json -g dart-dio -o ./dartdio-codegen
dartdio-codegen/lib/src/api
to see the use of the deprecatedDioError
classExpected behavior
The use of
DioError
andDioErrorType
for serialization errors should be switched toDioException
andDioExceptionType
Logs
No response
Screenshots
No response
Platform
macOS
Library version
4.10.0
Flutter version
3.10.4
Flutter channel
stable
Additional context