OpenAPITools / OpenAPITools/openapi-generator

[JAVA] Bug Including Non Null fields in response

Open
#4,149 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Description

Expect default nullable=false to generate @JsonInclude(JsonInclude.Include.NON_NULL) excluding non-null fields from being returned. This is the default behavior in swagger-codegen.

openapi-generator version

4.1.2

OpenAPI declaration file content or url
type: integer
nullable: false
Command line used for generation

mvn clean install

Steps to reproduce

Define API response in yml using OpenAPI 3 spec. Run maven to create generated classes.

Related issues/PRs

None.

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 OpenAPI 3 declaration containing type: integer and nullable: false, then run the reported mvn clean install generation flow for Java. Compare the generated response model with the expected @JsonInclude(JsonInclude.Include.NON_NULL) behavior; done means non-null fields are excluded as described.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.