OpenAPITools / OpenAPITools/openapi-generator
[BUG] [GO] generated code for specific responses is adding double return statement.
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- What's the version of OpenAPI Generator used?
- Have you search for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Bounty to sponsor the fix (example)
Description
When running the generator for go-experimental in some cases where the paths have specific status codes to return such as CreateImages/ (see https://github.com/outscale/osc-api/blob/3283cc733026d04905905e0d949fea858cee833b/outscale.yaml#L6323) the code generated add double return value to the function and the code results like the following:
This causes problems with go-vet it marks unreachable code.
openapi-generator version
4.2.0
OpenAPI declaration file content or url
https://raw.githubusercontent.com/outscale/osc-api/master/outscale.yaml
Command line used for generation
openapi-generator generate -i outscale.yaml -g go-experimental
Steps to reproduce
Run the following command:
openapi-generator generate -i outscale.yaml -g go-experimental
you can see the double return statement in oapi_image.go at line 149
Related issues/PRs
Suggest a fix
Remove this double line at:
https://github.com/OpenAPITools/openapi-generator/blob/99204ecd66b61df9d97d5b456a8f82d35febc0e1/modules/openapi-generator/src/main/resources/go-experimental/api.mustache#L334
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
Start with modules/openapi-generator/src/main/resources/go-experimental/api.mustache at line 334, then reproduce with the outscale.yaml specification and the command openapi-generator generate -i outscale.yaml -g go-experimental. Compare the generated oapi_image.go around line 149; done means the duplicate return is absent and go-vet no longer reports unreachable code.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100