swagger-api/swagger-codegen

[Java] Support enums in query params

Open

#1,347 opened on Oct 7, 2015

View on GitHub
 (13 comments) (8 reactions) (0 assignees)HTML (12,701 stars) (5,474 forks)batch import
Client: JavaEnhancement: Generalhelp wanted

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