Skip to content

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

@tobiiasl

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions