OpenAPITools / OpenAPITools/openapi-generator

[BUG][Dart] Getting Map<String, Object> instead of Map<String, dynamic>

Open
#15,670 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

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

I want to generate Map<String, dynamic> type but I'm getting Map<String, Object> instead. I'm talking about the initMap property in lib/models/device.dart. If I understood this part of the specification correctly, free-form objects can be anything (numbers, strings etc.) so the Object type is not correct. If I misunderstood it, is it possible to have dynamic type generated? Or why it is not? Thank you

openapi-generator version

Latest v6.6.0 .jar snapshot

OpenAPI declaration file content or url

Here is a gist: https://gist.github.com/Liniik/dca95f3a72e46f9d17544b312a2545aa

Generation Details

I'm using this command to generate the API: java -jar .\openapi-generator-cli-6.6.0-20230510.062557-69.jar generate -i .\openapi.yaml -g dart -o ./api

Steps to reproduce

From the given specification in the gist above, generate files via command in the paragraph above.

Related issues/PRs

Maybe #12165 could be somewhat related to it. But it was resolved so I don't know...

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the linked OpenAPI declaration and the documented Java generation command, then inspect the generated lib/models/device.dart file and its initMap property. Trace the Dart generator or template that determines this map value type and verify the result against the OpenAPI free-form object semantics. Done means the generated type matches the intended dynamic map type and relevant generation tests pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart
Domain
api, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.