swagger-api / swagger-api/swagger-codegen
[Dart] Unable to generate fromJson method for list of date time
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
If the swagger response contains a list of DateTime objects, It generates the wrong method for parsing from JSON.
For example for the below JSON:
{
"dates" : [ ... ]
}
It generates:
MyDto.fromJson(Map<String, dynamic> json) {
if (json == null) return;
dates =
DateTime.listFromJson(json['dates']);
}
So, the DateTime has no listFromJson method.
I'm using the online editor to generate dart client code.
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
Reproduce the example in the online editor and inspect the generated Dart deserialization for a list of DateTime values. Trace the generator template or entry point responsible for this output; done means the generated fromJson method uses a valid way to parse the dates list without calling DateTime.listFromJson.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100