Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rename json argument.
  • Loading branch information
noordawod committed May 15, 2023
commit fcce90cd8819481b37371c92dbdc471811cb74ac
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,19 @@ class ApiClient {
}
{{#native_serialization}}

Future<dynamic> deserializeAsync(String json, String targetType, {bool growable = false,}) async =>
Future<dynamic> deserializeAsync(String value, String targetType, {bool growable = false,}) async =>
// ignore: deprecated_member_use_from_same_package
deserialize(json, targetType, growable: growable);
deserialize(value, targetType, growable: growable);

@Deprecated('Scheduled for removal in OpenAPI Generator 6.x. Use deserializeAsync() instead.')
dynamic deserialize(String json, String targetType, {bool growable = false,}) {
dynamic deserialize(String value, String targetType, {bool growable = false,}) {
// Remove all spaces. Necessary for regular expressions as well.
targetType = targetType.replaceAll(' ', ''); // ignore: parameter_assignments

// If the expected target type is String, nothing to do...
return targetType == 'String'
? json
: deserialize(jsonDecode(json), targetType, growable: growable);
? value
: fromJson(json.decode(value), targetType, growable: growable);
}
{{/native_serialization}}

Expand All @@ -158,7 +158,7 @@ class ApiClient {

{{#native_serialization}}
/// Returns a native instance of an OpenAPI class matching the [specified type][targetType].
static dynamic deserialize(dynamic value, String targetType, {bool growable = false,}) {
static dynamic fromJson(dynamic value, String targetType, {bool growable = false,}) {
try {
switch (targetType) {
case 'String':
Expand Down Expand Up @@ -190,18 +190,18 @@ class ApiClient {
dynamic match;
if (value is List && (match = _regList.firstMatch(targetType)?.group(1)) != null) {
return value
.map<dynamic>((dynamic v) => deserialize(v, match, growable: growable,))
.map<dynamic>((dynamic v) => fromJson(v, match, growable: growable,))
.toList(growable: growable);
}
if (value is Set && (match = _regSet.firstMatch(targetType)?.group(1)) != null) {
return value
.map<dynamic>((dynamic v) => deserialize(v, match, growable: growable,))
.map<dynamic>((dynamic v) => fromJson(v, match, growable: growable,))
.toSet();
}
if (value is Map && (match = _regMap.firstMatch(targetType)?.group(1)) != null) {
return Map<String, dynamic>.fromIterables(
value.keys.cast<String>(),
value.values.map<dynamic>((dynamic v) => deserialize(v, match, growable: growable,)),
value.values.map<dynamic>((dynamic v) => fromJson(v, match, growable: growable,)),
);
}
}
Expand Down Expand Up @@ -240,7 +240,7 @@ Future<dynamic> decodeAsync(DeserializationMessage message) async {
// If the expected target type is String, nothing to do...
return targetType == 'String'
? message.json
: jsonDecode(message.json);
: json.decode(message.json);
}

/// Primarily intended for use in an isolate.
Expand All @@ -251,8 +251,8 @@ Future<dynamic> deserializeAsync(DeserializationMessage message) async {
// If the expected target type is String, nothing to do...
return targetType == 'String'
? message.json
: ApiClient.deserialize(
jsonDecode(message.json),
: ApiClient.fromJson(
json.decode(message.json),
targetType,
growable: message.growable,
);
Expand Down