swagger_parser icon indicating copy to clipboard operation
swagger_parser copied to clipboard

Regression in 1.24 with dart_mappable and default empty arrays

Open s9th opened this issue 7 months ago • 0 comments

Steps to reproduce

A field in json that looks like this

"languages": {
    "default": [],
    "type": "array",
    "items": {
        "type": "string"
    }
},

Is parsed into this this.languages = [], which cannot be compiled due to error "The default value of an optional parameter must be constant"

Prior to 1.24 it was parsed as required this.languages,

Expected results

Either the parse result should be required this.languages, or this.languages = const [],

Actual results

Image

Your OpenApi snippet

"languages": {
    "default": [],
    "type": "array",
    "items": {
        "type": "string"
    }
},

Dart version and used packages versions

Dart 3.8.0, dart_mappable 4.5.0, swagger_parser 1.24.0

s9th avatar May 27 '25 08:05 s9th