OpenAPITools / OpenAPITools/openapi-generator

[BUG] [JAVA]String type parameter in post request body was generated as Java class type

Open
#8,184 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

used cli to create a client sdk jar file: java -jar openapi-generator-cli-5.0.0-beta3.jar generate --input-spec synopsys-coverity-coverity-connect-2020.12-resolved.yaml -g java -o connectAPIclient-2020.12 .

in the swagger yaml file, two String parameters (FilterKey and FilterMatchMode )were defined in the post request body. the only difference is FilterMatchMode is a enum string, it only allows two values ("oneOrMoreMatch" or "noneMatch"), but in the auto Generated java code, the FilterKey was generated as a string type, but FilterMatchMode was generated as a FilterMatchMode class type, both should be generated as String type.

Swagger definition:
`

FilterKey string

FilterMatchMode string
values:
oneOrMoreMatch: (Default) At least one of the values must match the item.
noneMatch: None of the values may match the item.
Enum:[ oneOrMoreMatch, noneMatch ]

Auto generated JAVA code: @javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.JavaClientCodegen", date = "2020-12-12T03:14:15.736Z[GMT]")
public class FilterElement {
@SerializedName("filterKey")
private String filterKey = null;

@SerializedName("matchMode")
private FilterMatchMode matchMode = null;
`

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 openapi-generator-cli 5.0.0-beta3 command and the referenced Synopsys Coverity YAML specification. Inspect the generated Java FilterElement class, comparing the FilterKey and FilterMatchMode fields; done means both string-valued parameters are generated as String rather than FilterMatchMode.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
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.