Skip to content

[BUG][Dart][Dio] Deserialisation of Map<String, List<String>> fails with 'Unknown type on deserialization' #15863

@Smibser

Description

@Smibser

Bug Report Checklist

  • Have you provided a minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

In my json spec file, I have a map with lists as values. In the generated code, the list somehow loses his type and I get the error that the type is underspecified

openapi-generator version

6.6.0

OpenAPI declaration file content or url

This is the part of the spec file

"schema": {
    "type": "object",
    "additionalProperties": {
        "type": "array",
        "items": {
            "type": "string"
        }
    }
}

And this is the specific type in the generated dart code

specifiedType: const FullType(BuiltMap, [FullType(String), FullType(BuiltList)])
Suggest a fix

I debugged through the generated code and found that the cause of the error is in built_list_serializer.dart. In the deserialize method it checks if the type is underspecified by checking if the type has parameters (specifiedType.parameters.isEmpty), which is empty here. But in my opinion here should be a parameter FullType(String).
That's why I think the specific type of the list is just missing. I would expect something like this

specifiedType: const FullType(BuiltMap, [FullType(String), FullType(BuiltList, [FullType(String)])])
Related issues/PRs

This issue seems to be similar
#15573

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions