Skip to content
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

Using additionalProperties:true results in type error in generated code #12

Open
timalenustmf opened this issue May 10, 2023 · 0 comments · May be fixed by #13
Open

Using additionalProperties:true results in type error in generated code #12

timalenustmf opened this issue May 10, 2023 · 0 comments · May be fixed by #13

Comments

@timalenustmf
Copy link

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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant