swagger-api / swagger-api/swagger-codegen

[JAVA] there is no way to deal with duplicated names

Open
#10,916 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

I have a swaggery.json that contains duplicated variable name as path and query parameters. swagger-codegen doesn't provide an option to deal with such collisions.

There is no way to update swagger.json because it's coming from external resource provided by 3rd party.

Maybe, there is some workaround?

Swagger-codegen version

3.0.24

Swagger declaration file content or url
    "/items/{itemId}/properties" : {
      "get" : {
        "tags" : [ "Item Property" ],
        "summary" : "Get list of Item Property items matched given criteria",
        "operationId" : "select_8",
        "parameters" : [ {
          "name" : "itemId",
          "in" : "path",
          "description" : "Id of a Item",
          "required" : true,
          "schema" : {
            "type" : "integer",
            "format" : "int64"
          }
        }, {
          "name" : "query_offset",
          "in" : "query",
          "description" : "",
          "schema" : {
            "type" : "integer",
            "format" : "int32"
          }
        }, {
          "name" : "query_limit",
          "in" : "query",
          "description" : "",
          "schema" : {
            "type" : "integer",
            "format" : "int32"
          }
        }, {
          "name" : "order_by",
          "in" : "query",
          "description" : "",
          "style" : "form",
          "explode" : true,
          "schema" : 
{"name" : "itemId",
          "in" : "query",
          "required" : false,
          "schema" : {
            "type" : "integer",
            "format" : "int64"
          }
        } ],
        "responses" : {
          "200" : {
            "description" : "Successful operation",
            "content" : {
              "application/json" : {
                "schema" : {
                  "$ref" : "#/components/schemas/Item"
                }
              }
            }
          }
        }
      },
Command line used for generation
swaggerSources {
    retrofit2 {
        inputFile = file("${projectDir}/../schemas/swagger.json")
        code {
            language = 'java'
            library = 'retrofit2'
            additionalProperties = [
                    modelPackage           : "retrofit2.model",
                    apiPackage             : "retrofit2",
                    dateLibrary: 'java8',
                    interfacesOnly: 'true'
            ]
        }
    }
}

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 reproducing generation with the provided swagger.json and the Gradle swaggerSources configuration for the Java retrofit2 library. Trace how the path and query parameters named itemId are handled, then define and verify an option for resolving that collision without changing the external specification.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.