swagger-api / swagger-api/swagger-codegen-generators

[Java generator] Generate various overloads for functions when some arguments are optional

Open
#1,116 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
299
Forks
439
PR merge metrics
No merged PRs in 30d

Description

Assume you have an endpoint search with arguments:

  • searchString - required

Java generator will generate something like:

public SearchPreview search(String searchString)

When I add an optional argument int limit to the endpoint, the Java generator will generate

public SearchPreview search(String searchString, int limit)

All the clients using the original search(String searchString) will no longer work. They will have to change their code to use the new function because swagger generator does not generate a search overload without the optional parameters.

It would be great if both methods would be available:

public SearchPreview search(String searchString)
public SearchPreview search(String searchString, int limit)

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 in the Java generator's method-generation path and trace how endpoint arguments become generated client methods. Confirm the behavior for an endpoint with one required and one optional argument; done means both the original single-argument overload and the overload including the optional argument are generated.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.