Ask a Question

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

pap
New Contributor

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 4
MConneely
Staff

@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
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. 

 

 

 

 

pap
New Contributor

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

 

 

pap
New Contributor

I created a sample TEST API which demonstrates the issue. 

It is a public API.

I also added swaggerhub-support as a collaborator to this API. 

 

The API is here: 

 

https://app.swaggerhub.com/apis/hibu/TEST_API_001/1.0.0

 

If you generate from this API Client SDK code in Java, you will see the issue. 

 

Several methods are generated which all have duplicate parameters like e.g. 

 

public Response findAvailableNumbersByTheirIds(Integer numberId, Integer numberId) throws ApiException { 

... 

}

 

Of course this Java code does not compile. 

 

Please take a look. 

 

 

cancel
Showing results for 
Search instead for 
Did you mean: