Forum Discussion

pap's avatar
pap
New Contributor
3 years ago

Bug when generating Java client-side code - duplicate parameter ?

Hello, 

 

We have an API which has an endpoint which defines two parameters like these:


parameters:
- name: number_id
in: path
description: The group id.
required: true
schema:
type: integer
description: The group id.
format: int32

...

- name: NumberId
in: query
description: Id of number.
schema:
type: integer
description: Id of number.
format: int32
nullable: true

...

 

It is not our own API, we got the API definition file from one of our vendors.

So I have no control over the API definition JSON/YAML file. 

 

When I import it in SwaggerHub it is marked as VALID. 

 

But later, when I try to generate client-side java code from it in SwaggerHub (from that same valid API definition), I get code generated this way   

 


public SomeResponseModel apiNumbersNumberIdConversationsGet(Integer numberId, ..., Integer numberId, ...) throws ApiException {
...

}

 And this of course doesn't compile because it has duplicate numberId parameter.

 

Is this a bug in the Swagger Hub codegen module?  

Seems to me it's just assigning the same Java parameter name for two different endpoint parameters, which doesn't seem right. 

 

 

Thanks in advance.

 

 

 

 

4 Replies

  • pap 
    are you working with SwaggerHub SaaS or On-Prem?

     

    The generated Java code from SaaS version should give you something like the following

     

    searchaccountsCall(Integer numberId, Integer numberId2, Integer......)


    If you could give a little bit more info, it might help look in to the issue further

    • pap's avatar
      pap
      New Contributor

      Hello MConneely

       

      What other info do you need? 

      I provided the exact scenario under which the code generation fails. 

       

      You say it should generate this but I saw it doesn't generate it this way. 

       

      I login to https://app.swaggerhub.com/ so I guess it's SaaS. 

       

      Do you want me to create a sample API definition and refer you to it? 

       

       

      Thanks in advance.