Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #6869
Closed
Open
Issue created Jul 06, 2020 by Administrator@rootContributor

[REQ][Java] Enhance POJO generation with Optional

Created by: thoroughsoft

Is your feature request related to a problem? Please describe.

Currently a POJO is generated with either direct access returning null or through the proprietary JsonNullable class. It should also be possible to generate the POJO without the method returning null, that is, use Optional for this case instead. Since it has been discussed before in other threads, this enhancement does NOT mean replacing the usage of the JsonNullable class, only changing the returned data type from the standard get method to use Optional. The getXXX_JsonNullable class remains. This enhancement means that in most cases the proprietary JsonNullable class stays hidden from the rest of the code while at the same time offering the full api of Optional.

Describe the solution you'd like

By setting the parameter 'useOptionalInApi' the code generator automatically adds Optional to the get methods. Note the different name to the already existing 'useOptional' to avoid conflicting/undesired output.

Describe alternatives you've considered

Manually changing the code every time it is generated. How error prone is that...?

Additional context

The code is ready, including test cases.

Assignee
Assign to
Time tracking