swagger-api / swagger-api/swagger-codegen

Swagger generation issue with @JsonInclude(JsonInclude.Include.NON_NULL)

Open
#12,515 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

When I am trying to create model and pojo class using Swager code generation, I wanted to have @JsonInclude(JsonInclude.Include.NON_NULL) annotation in some module but not all modules Can we have this as configuration in pom.xml file for the module where we need this?

Swagger-codegen version

3.0.3

Swagger maven plugin version

3.0.3

Language

jaxrs-jersey

JSON include , definition.yaml
Swagger declaration file content or url

We added this to pojo.mustache class
{{#notNullJacksonAnnotation}}
@JsonInclude(JsonInclude.Include.NON_NULL)
{{/notNullJacksonAnnotation}}

We added this to model.mustache class
import com.fasterxml.jackson.annotation.JsonInclude;

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 by reviewing the existing pom.xml configuration and the reported pojo.mustache and model.mustache templates. Determine how a module-specific setting could control the JsonInclude annotation for jaxrs-jersey generation; done means the setting applies only to the selected module and leaves other modules unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 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.