swagger-api / swagger-api/swagger-codegen

Java Clients: Support Optional<T> on model classes when a field is not required

Open
#2,485 28 comments 23 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: Java Enhancement: General
Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

I think (similar to the swift client) that is would be nice, if the generated clients had an option to enable the use of the Optional<T> type on model fields that are not required.

This should both include and option to use

  • com.google.common.base.Optional
  • java.util.Optional<T>

Supporting guava is probably needed for all those people that are not using java8 for whatever reason (for instance Android projects).

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

No specific files or tests are named. Start by locating the Java client generation templates and option handling, then compare the Swift client's analogous support mentioned in the issue; done means optional non-required model fields can be generated with either Guava Optional or java.util.Optional.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.