swagger-api / swagger-api/swagger-codegen
[JAVA][SPRING-CLOUD] `spring-cloud` library generated code unusable with Java 8
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
As the interfaces generated when using the Spring library builds an interface with a default method when using Java 8, the Feign integration is rendered inoperable as Feign will run the default method rather than initiating the HTTP call.
Swagger-codegen version
2.2.3
Swagger declaration file content or url
See https://github.com/wjam/swagger-codegen-spring-cloud for an example
Command line used for generation
Maven library used. Configuration is in the GitHub repo mentioned above
Steps to reproduce
Run mvn clean verify on the GitHub repo mentioned above.
Suggest a fix/enhancement
Without considering any backwards incompatibility issues, I'd say drop the default method as it is not only useless but also has a dangerous default return value of 200 rather than doing something like throwing java.lang.UnsupportedOperationException.
Another alternative, less backwards incompatible way, would be to allow the control over whether the default methods are generated or not.
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 by running mvn clean verify in the linked swagger-codegen-spring-cloud example and inspect the generated Java 8 interfaces used by Feign. Trace the Spring template or entry point that emits the default method, then verify that generated Feign calls initiate HTTP requests rather than returning the default response.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100