swagger-api / swagger-api/swagger-codegen

[JAVA] Bug generating HashMap class

Open
#9,051 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

I am trying to generate a HashMap class, but no class is generated and a plain Java Map is used where the class ContextHeaders should be used. It is working properly in 2.3.1 with swagger 2 but not in 3.0.3 with swagger 3.0 (3.0.3 still correctly generates the swagger 2.0 contract)

In 2.3.1 it generates ContextHeaders.java and it's used in the RulesUser class:

  @JsonProperty("contextHeaders")
  private ContextHeaders contextHeaders = null;

But in 3.0.3 there is no class and in the RulesUser class it has:

  @JsonProperty("contextHeaders")

  private Map contextHeaders = null;
Swagger-codegen version

3.0.3

Swagger declaration file content or url

swagger.json
swagger-2.3.1.json

Command line used for generation

swagger-client-config.json
java -jar ./swagger-codegen.jar generate -c ./swagger-client-config.json -i ./swagger.json -l java -o generated-client/

Steps to reproduce

Run the swagger codegen 3.0.3 against the swagger.json file with the config swagger-client-config.json.

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 with the linked swagger.json, swagger-client-config.json, and the Java generation command to reproduce the output. Compare the generated RulesUser class and the missing ContextHeaders class with the Swagger 2.3.1 result; done means the OpenAPI 3 input generates and uses ContextHeaders instead of a plain Map.

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
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.