-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
dart-dio improvements #6047
dart-dio improvements #6047
Conversation
modules/openapi-generator/src/main/resources/dart-dio/api.mustache
Outdated
Show resolved
Hide resolved
If no further feedback on this PR, I'll merge it over the weekend. |
@jaumard thanks for the PR, which has been included in the v4.3.1 release: https://twitter.com/oas_generator/status/1258057660974329861 |
* fix runtime deserialisation * add security support for dart dio * regenerate dart dio sample * update dio pubspec.mustache deps * check response type before parsing * add default dateTime serializer * regenerate sample
@@ -88,12 +88,12 @@ class {{classname}} { | |||
|
|||
{{#isListContainer}} | |||
final FullType type = const FullType(BuiltList, const [const FullType({{returnBaseType}})]); | |||
BuiltList<{{returnBaseType}}> dataList = _serializers.deserialize(jsonDecode(response.data), specifiedType: type); | |||
BuiltList<{{returnBaseType}}> dataList = _serializers.deserialize(response.data is String ? jsonDecode(response.data) : response.data, specifiedType: type); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After this change, you cannot have a 'text/plain' response, as it tries to apply jsonDecode on it.
:(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With 'text/plain' response you shouldn't arrived here as you don't need to deserialize at all
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, but it was trying to deserialize a text/plain response.
* fix runtime deserialisation * add security support for dart dio * regenerate dart dio sample * update dio pubspec.mustache deps * check response type before parsing * add default dateTime serializer * regenerate sample
fix #6044
fix #6026
PR checklist
./bin/
(or Windows batch scripts under.\bin\windows
) to update Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit, and these must match the expectations made by your contribution. You only need to run./bin/{LANG}-petstore.sh
,./bin/openapi3/{LANG}-petstore.sh
if updating the code or mustache templates for a language ({LANG}
) (e.g. php, ruby, python, etc).master
,4.3.x
,5.0.x
. Default:master
.cc @ircecho (2017/07) @swipesight (2018/09) @jaumard (2018/09) @nickmeinhold (2019/09) @athornz (2019/12) @amondnet (2019/12)