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
  • #5451
Closed
Open
Issue created Feb 26, 2020 by Administrator@rootContributor

[REQ] [Java] use a builder pattern for parameters?

Created by: bgong-mdsol

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

Not an issue per se, just a better way to achieve the same result.

Describe the solution you'd like

Currently parameters of an endpoint become parameters on a method.

Some endpoints have many parameters and as a result, the method will have 10s of parameters. Something like:

search(uuid, uuid2, uuid3, name, some_bool, other_bool, this_int, this_other_uuuid, other_bool, name2, name3)

The problems are:

  • Usually you only need a couple of params so you call this with 2 params and 9 null
  • It is very difficult to review and very error prone
  • If the openapi spec changes the order in which they write the params or if they add a param in the first position, all the params will shift position. If types match, the code will compile but the outgoing call would be totally different.

To mitigate that, we used a builder pattern in our own templates to handle parameters, usage roughly looks like that:

String operation = "unlock";
String operatorUuid = "596ad8ad-40f3-4fcd-b8af-7e7be5d8337c";
ServiceClient myApi = createServiceClient();

APIpermissionsIndexParams params = APIpermissionsIndexParams.builder()
  .operation(operation)
  .operatorUuid(operatorUuid)
  .build();

List<Permission> response = myApi.permissionsIndex(params);

Describe alternatives you've considered

Using Map<String, Object>.

Additional context

N/A


We would like to contribute the code back upstream but before opening a PR we'd like to hear the thoughts of the java tech committee.

Thanks!

@bbdouglas @sreeshas @jfiala @lukoyanov @cbornet @jeff9finger @karismann @Zomzog @lwlee2608 @bkabrda

Assignee
Assign to
Time tracking