swagger-api / swagger-api/swagger-codegen

Pass parameters as an object for get operations with too many params

Open
#3,966 4 comments 10 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Description

We have GET operations with 15-20 or more parameters. The API client code generated for these has methods with a large number of parameters.

Collapsing these parameters into a POJO and pass that in to the API method would make the code easier to maintain.

Swagger-codegen version

Pulled in the latest code from master on 2016.10.11.

Swagger declaration file content or url

Command line used for generation

We are using the Java client.

Steps to reproduce

This is a feature request, not a bug.

Related issues

I didn't see a related issue.

Suggest a Fix

I added a variable to swagger spec file called "x-paramCollapseThreshold".

If this parameter exists with a positive value, the get operations with more params than that have a POJO with setters generated. An instance of this class is passed to the GET API method.

I want to see if I should make this a pull request if this is something others are interested in.

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 by tracing Java client generation and how the Swagger declaration is read for the proposed x-paramCollapseThreshold setting. Done means GET operations above the threshold receive a generated parameter POJO with setters and accept that object, while operations below it retain their current signatures; no file or test is identified in the issue.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.