swagger-api / swagger-api/swagger-codegen

[Java] Support enums in query params

Open
#1,347 13 comments 8 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

In Java generation, enums are generated when they are part of a definition object but not when they are a direct method property.
For instance:

"/pet/findByStatus": {
      "get": {
        "tags": [
          "pet"
        ],
        "summary": "Finds Pets by status",
        "description": "Finds Pets by status",
        "operationId": "findPetsByStatus",
        "produces": [
          "application/json",
          "application/xml"
        ],
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "description": "Status value that for filter",
             "type": "string",
             "enum": ["available", "pending", "sold"]
            }
         ],
        "responses": {
          "200": {
            "description": "successful operation",
            "schema": {
              "type": "array",
              "items": {
                "$ref": "#/definitions/Pet"
              }
            }
          }
        }

Generates "status" as a String not as an enum.

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 source file or test is named. Start by tracing Java generation for direct query parameters using the /pet/findByStatus example, then verify that the status parameter is generated as an enum with available, pending, and sold values rather than as String.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend-api-design
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.