swagger-api / swagger-api/swagger-codegen
[Java] Extra comma in arguments when generating Retrofit2 api
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
When I tries to generate apis using Retrofit2 I got uncompilable code because of extra commas
// skipped
public interface UserApi {
/**
* Get information about user
* An application should invoke this method just after the open session step to know the user's account description. A server application which is interested by retrieving data of the user using this method must invoke it only when it is necessary and then cache the result.
* @param alcUserId Identifier of the Session (required)
* @param loginName Login name of the user to retrieve the account description. (required)
* @return Call<User>
*/
@GET("users/{loginName}")
Call<User> getUserInfo(
,@retrofit2.http.Path("loginName") String loginName
);
}
Note comma before @retrofit2.http.Path("loginName") String loginName.
Swagger-codegen version
3.0.0-SNAPSHOT
Swagger declaration file content or url
Yaml file is here:
https://gist.github.com/Klemsus/f58803b8c94832705dec4b3895f27d49
Command line used for generation
java -jar swagger-codegen-cli.jar generate -l java -o rest -i userapi.yml -Dlibrary=retrofit2
Steps to reproduce
- Generate API
- Open in IDE - it shows an error
Suggest a fix/enhancement
The problem is in cookie type argument that parsed into empty argument (and this is correct behavior, I don't want this as argument), but comma still appears.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the linked YAML and the shown swagger-codegen command using the Retrofit2 library, then inspect how the Java API method arguments are rendered when the cookie type argument is empty. Done means the generated UserApi.java has no leading comma before the loginName parameter and compiles successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100