forked from loafle/openapi-generator-original
[dart-dio] Fixes errors when primitive return types are attempted to … (#7411)
* [dart-dio] Fixes errors when primitive return types are attempted to be deserialized as json * Updates samples * Removes old files
This commit is contained in:
@@ -94,6 +94,10 @@ class {{classname}} {
|
||||
onReceiveProgress: onReceiveProgress,
|
||||
){{#returnType}}.then((response) {
|
||||
|
||||
{{#returnTypeIsPrimitive}}
|
||||
var data = response.data as {{{returnType}}};
|
||||
{{/returnTypeIsPrimitive}}
|
||||
{{^returnTypeIsPrimitive}}
|
||||
{{#isResponseFile}}
|
||||
final data = response.data;
|
||||
{{/isResponseFile}}
|
||||
@@ -113,6 +117,7 @@ class {{classname}} {
|
||||
final data = _serializers.deserializeWith<{{{returnType}}}>(serializer, response.data is String ? jsonDecode(response.data) : response.data);
|
||||
{{/isArray}}
|
||||
{{/isResponseFile}}
|
||||
{{/returnTypeIsPrimitive}}
|
||||
|
||||
return Response<{{{returnType}}}>(
|
||||
data: data,
|
||||
|
||||
@@ -83,8 +83,7 @@ class StoreApi {
|
||||
onReceiveProgress: onReceiveProgress,
|
||||
).then((response) {
|
||||
|
||||
final serializer = _serializers.serializerForType(Map);
|
||||
final data = _serializers.deserializeWith<Map<String, int>>(serializer, response.data is String ? jsonDecode(response.data) : response.data);
|
||||
var data = response.data as Map<String, int>;
|
||||
|
||||
return Response<Map<String, int>>(
|
||||
data: data,
|
||||
|
||||
@@ -250,8 +250,7 @@ class UserApi {
|
||||
onReceiveProgress: onReceiveProgress,
|
||||
).then((response) {
|
||||
|
||||
final serializer = _serializers.serializerForType(String);
|
||||
final data = _serializers.deserializeWith<String>(serializer, response.data is String ? jsonDecode(response.data) : response.data);
|
||||
var data = response.data as String;
|
||||
|
||||
return Response<String>(
|
||||
data: data,
|
||||
|
||||
@@ -83,8 +83,7 @@ class StoreApi {
|
||||
onReceiveProgress: onReceiveProgress,
|
||||
).then((response) {
|
||||
|
||||
final serializer = _serializers.serializerForType(Map);
|
||||
final data = _serializers.deserializeWith<Map<String, int>>(serializer, response.data is String ? jsonDecode(response.data) : response.data);
|
||||
var data = response.data as Map<String, int>;
|
||||
|
||||
return Response<Map<String, int>>(
|
||||
data: data,
|
||||
|
||||
@@ -250,8 +250,7 @@ class UserApi {
|
||||
onReceiveProgress: onReceiveProgress,
|
||||
).then((response) {
|
||||
|
||||
final serializer = _serializers.serializerForType(String);
|
||||
final data = _serializers.deserializeWith<String>(serializer, response.data is String ? jsonDecode(response.data) : response.data);
|
||||
var data = response.data as String;
|
||||
|
||||
return Response<String>(
|
||||
data: data,
|
||||
|
||||
@@ -147,8 +147,7 @@ class FakeApi {
|
||||
onReceiveProgress: onReceiveProgress,
|
||||
).then((response) {
|
||||
|
||||
final serializer = _serializers.serializerForType(bool);
|
||||
final data = _serializers.deserializeWith<bool>(serializer, response.data is String ? jsonDecode(response.data) : response.data);
|
||||
var data = response.data as bool;
|
||||
|
||||
return Response<bool>(
|
||||
data: data,
|
||||
@@ -251,8 +250,7 @@ class FakeApi {
|
||||
onReceiveProgress: onReceiveProgress,
|
||||
).then((response) {
|
||||
|
||||
final serializer = _serializers.serializerForType(num);
|
||||
final data = _serializers.deserializeWith<num>(serializer, response.data is String ? jsonDecode(response.data) : response.data);
|
||||
var data = response.data as num;
|
||||
|
||||
return Response<num>(
|
||||
data: data,
|
||||
@@ -303,8 +301,7 @@ class FakeApi {
|
||||
onReceiveProgress: onReceiveProgress,
|
||||
).then((response) {
|
||||
|
||||
final serializer = _serializers.serializerForType(String);
|
||||
final data = _serializers.deserializeWith<String>(serializer, response.data is String ? jsonDecode(response.data) : response.data);
|
||||
var data = response.data as String;
|
||||
|
||||
return Response<String>(
|
||||
data: data,
|
||||
|
||||
@@ -83,8 +83,7 @@ class StoreApi {
|
||||
onReceiveProgress: onReceiveProgress,
|
||||
).then((response) {
|
||||
|
||||
final serializer = _serializers.serializerForType(Map);
|
||||
final data = _serializers.deserializeWith<Map<String, int>>(serializer, response.data is String ? jsonDecode(response.data) : response.data);
|
||||
var data = response.data as Map<String, int>;
|
||||
|
||||
return Response<Map<String, int>>(
|
||||
data: data,
|
||||
|
||||
@@ -250,8 +250,7 @@ class UserApi {
|
||||
onReceiveProgress: onReceiveProgress,
|
||||
).then((response) {
|
||||
|
||||
final serializer = _serializers.serializerForType(String);
|
||||
final data = _serializers.deserializeWith<String>(serializer, response.data is String ? jsonDecode(response.data) : response.data);
|
||||
var data = response.data as String;
|
||||
|
||||
return Response<String>(
|
||||
data: data,
|
||||
|
||||
Reference in New Issue
Block a user