Skip to content

Compile error for property of type "object" with default value {} #85

Description

@tobiiasl

In our auto-generated input json file we have this object:

      "DataStream": {
        "properties": {
          "metadata": {
            "type": "object",
            "title": "Metadata",
            "description": "Arbitrary metadata in key/value pairs.",
            "default": {}
          }
        },
        "type": "object",
        "title": "DataStream"
      },

This results in this invalid dart code after running openapi_spec:

 abstract class DataStream with _$DataStream {
  const DataStream._();

  const factory DataStream({
    @Default(dynamic()) dynamic metadata,
  }) = _DataStream;
}

The error message is:

'dynamic' isn't a function.
Try correcting the name to match an existing function, or define a method or function named 'dynamic'.

Is this a bug or is the json input not on a valid format?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions