You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The second parameter passed to deserialize (targetType), "Map<String, String>", contains space after a comma.
if (value isMap&& (match = _regMap.firstMatch(targetType)) !=null) {
// targetType resolves to ' String' with a space in front and recursive call below will not find matching type
targetType = match![1]!; // ignore: parameter_assignments.returnMap<dynamic, BaseType>.fromIterables(
value.keys,
value.values.map((dynamic v) =>deserialize<BaseType, BaseType>(v, targetType, growable: growable)),
) asReturnType;
}
Fixing the above by adding .trim() causes a second issue:
Error: type '_Map<dynamic, String>' is not a subtype of type 'Map<String, String>' in type cast
Therefore the correct code for the above snippet, considering that _regMap is looking for Map<String, ...> should be:
Bug Report Checklist
Description
Deserializing fails for any type of dictionary return type for 'json_serializable'. Even as simple Map<String, String>.
The problem is here.
openapi-generator version
7.8.0
OpenAPI declaration file content or url
Generation Details
Steps to reproduce
Related issues/PRs
Suggest a fix
In
deserialize.mustache
, the regular expression for Map type looks looks like this:... it will pick up everything after a comma.
Generated code for the above spec will have this snippet:
The second parameter passed to deserialize (targetType), "Map<String, String>", contains space after a comma.
Fixing the above by adding .trim() causes a second issue:
Error: type '_Map<dynamic, String>' is not a subtype of type 'Map<String, String>' in type cast
Therefore the correct code for the above snippet, considering that
_regMap
is looking forMap<String, ...>
should be:I will do a PR for this in a minute.
The text was updated successfully, but these errors were encountered: