Using additionalProperties:true results in type error in generated code
timalenustmf opened this issue · comments
Tim Alenus commented
I have a schema Parent.yml as follows:
type: object
properties:
test:
type: object
additionalProperties: true
After running the build_runner this results in a type error in the generated class ParentTest implements OpenApiContent
in the file *.api.openapi.dart
The type error from my IDE reads as follows: The argument type 'Iterable<MapEntry<String, dynamic>>' can't be assigned to the parameter type 'Iterable<MapEntry<String, Object>>'
class ParentTest implements OpenApiContent {
ParentTest();
factory ParentTest.fromJson(Map<String, dynamic> jsonMap) =>
_$PersonGroupsFromJson(jsonMap)
.._additionalProperties.addEntries(
jsonMap.entries.where((e) => !const <String>{}.contains(e.key)));
final Map<String, Object> _additionalProperties = <String, Object>{};
}
This can be solved by changing the type of _additionalProperties
to Map<String, dynamic>