swagger-api / swagger-api/swagger-codegen

[Java] Does not support Map of Map of String or other type

Open
#3,241 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: Java help wanted Issue: Bug
Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

Currently, Java does not support Map of Map of String or other type

public class MapTest   {
  @SerializedName("map_map_of_string")
  private Map<String, Map<String, String>> mapMapOfString = new HashMap<String, Map<String, String>>();

As shown above, the inner Map is not mapped to HashMap

Swagger-codegen version

Latest master (Jun 28, 2016)

Suggest a Fix

The issue likely has to do with getTypeDeclaration in modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractJavaCodegen.java

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

Start in modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractJavaCodegen.java, at getTypeDeclaration, and trace how nested Java Map types are handled. Done means the generated MapTest field maps the inner Map to HashMap for Map<String, Map<String, String>> and other nested value types.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.