Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #8029
Closed
Open
Issue created Nov 26, 2020 by Administrator@rootContributor3 of 6 checklist items completed3/6 checklist items

[BUG][Dart] Map.mapFromJson is generated, but there's no such method on map.

Created by: Grohden

Bug Report Checklist

  • Have you provided a full/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

Dart generator may have a problem dealing with a Map of Maps (something like Map<String, Map<String>>), here's a screenshot from a generated code:

image

There's no such thing as Map.mapFromJson (at least I couldn't find it in dart 1 or 2 docs), so maybe there's a problem with the generator template.

openapi-generator version

5.0.0-beta3

OpenAPI declaration file content or url

https://gist.github.com/Grohden/13d012470a9860f3dc26c219c4674361

Steps to reproduce

Download the gist json, and run:

java -jar ./openapi-generator-cli.jar generate -g dart -i ./test.json -o ./api
Related issues/PRs

Probably #7850 (?)

Suggest a fix

The problem may be here: https://github.com/OpenAPITools/openapi-generator/blob/4dc8d2a3514af15ac13624d4dc8e2e179749e5bd/modules/openapi-generator/src/main/resources/dart2/class.mustache#L149-L152

I've removed the mapFromJson call from my template (copied today from the master) and I haven't found any issues with the dart analyzer.. but I haven't tested it in runtime either, so I'm not sure.

Another way to fix it could be to add the mapFromJson as an extension method for maps.. but I'm not sure how it would work

Fun fact (?): I've copied all the dart generator sources, converted them to kotlin and generated a client just to see if could fix the issue.. but the project is too complex for me to understand how/where that Map was generated, and I found out that some of my problems were solved yesterday on the templates 😆 (😢)

Assignee
Assign to
Time tracking