[JAVA] How do I add @JsonInclude(JsonInclude.Include.NON_NULL) as part of code gen
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start by reading the swagger-codegen-maven-plugin configuration around the Maven generate-sources phase and the referenced pojo.mustache template. Determine whether an environment or plugin property can control this annotation; done means generated Java POJOs include it during mvn clean generate-sources package without manual edits or a separately maintained template.
Written by the indexing model from the issue text.
Description
Description
I am using the swagger-codegen-maven-plugin to generate the models from my swagger yaml. I want to add the @JsonInclude(JsonInclude.Include.NON_NULL) annotation against each pojo that is generated and since we are using CI, we don't want to manually add this annotation after the classes (pojos) are generated. We also don't have the option of updating the pojo.mustache file either since we are using the swagger-codegen-maven-plugin plugin and not invoking the swagger-codegen jar directly.
Is there a way we can add this as a config or environment property as part of the maven generate-sources execution stage?
Swagger-codegen version
2.1.4
Swagger declaration file content or url
Command line used for generation
mvn clean generate-sources package
Steps to reproduce
Given a sample swagger yaml, try running mvn clean generate-sources package.
Related issues/PRs
https://github.com/swagger-api/swagger-codegen/issues/5309
Suggest a fix/enhancement
If we can pass this as a env property or configuration while defining my maven generate-sources, then we don't need to make any new templates - creating a new template for pojo.mustache and configuring it as part of CI may not always be a viable option.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from swagger-api/swagger-codegen
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
swagger-api/swagger-codegen#12755 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
swagger-api/swagger-codegen#12445 ·
-
security vulnerability
Difficulty 1/5 Under an hour Newbie friendliness 62/100
swagger-api/swagger-codegen#11942 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
swagger-api/swagger-codegen#11812 · 1 reaction ·
-
security vulnerability
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
swagger-api/swagger-codegen#11594 ·
All issues in swagger-api/swagger-codegen
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
newrelic-experimental/preflight#793 · 1 comment ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
babalae/bettergi-scripts-list#3674 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
caddyserver/caddy#8046 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
zilliztech/memsearch#759 ·
-
comp/cron P2 sweeper:risk-automation type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
NousResearch/hermes-agent#117792 · 1 comment ·