swagger-api / swagger-api/swagger-codegen
[java] response return does not generate properly
@HugoMario is already working on this.
Since Mar 1, 2018.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
Response return with a string parameter should ideally generate the code with String. But in certain scenario it does not generate. This is consistent behaviour , easily reproducible.
Swagger-codegen version
any latest version
Swagger declaration file content or url
If the below response code is written for "CreateUser"
'201':
description: The request has been fulfilled, and a new resource is created .
schema:
type: "string"
description: ID of the Object created
then as expected
public String createUser(User body)
but where as if below response code is written for "CreateUser"
'200':
description: OK. Request is OK.
'201':
description: The request has been fulfilled, and a new resource is created .
schema:
type: "string"
description: ID of the Object created
notice the subtle change in the above that the first response code 200 does not return anything but second response code 201 returns String
now when we generate the code
public void createUser(User body)
Command line used for generation
java -jar /usr/share/swagger/swagger-codegen.jar generate -l java -c config.json -i index.yaml
Steps to reproduce
Very easy , just replace the above in pet store example and generate the code
Related issues/PRs
Suggest a fix/enhancement
It is not clear what is expected behavior , should we mention only one return response code ? or will the generator always take the return type of first response code ?
What is the appropriate behavior ?
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.
Assessment
This issue has not been assessed yet.