OpenAPITools / OpenAPITools/openapi-generator
[BUG][Dart][Dio] Deserialisation of Map<String, List<String>> fails with 'Unknown type on deserialization'
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
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
https://github.com/OpenAPITools/openapi-generator/issues/15573
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue from the supplied OpenAPI schema with OpenAPI Generator 6.6.0, then inspect the generated Dart code and built_list_serializer.dart, especially deserialize and its specifiedType check. Compare the emitted FullType for BuiltMap with the expected nested FullType(BuiltList, [FullType(String)]); done means deserialization succeeds without the unknown-type error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100