Forum Discussion
I am not able to reproduce the issue with the example provided, both find and create get correctly resolved; which swagger artifact and version are you using, and how is that configured? and whatever signficant detail.
Hi,
Thanks for your answer.
I've written a sample project to show the problem.
Here is the repository.
https://github.com/githubjul/test-swagger-with-interfaces
The creation of this test allows me to understand exactly where is the problem, it's a little more tricky than I thought.
First of all, you're absolutely right : there is no problem with default method in interfaces.
My problem is a mix between default method in interface and inheritance.
First interface :
public interface OriginalEndpoint<C> { String originalEndpoint(C c); }
Second interface :
public interface SecondEndpoint<C> extends OriginalEndpoint<C> { @GET @Path("/{id}") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "400", description = "Bad Request"), @ApiResponse(responseCode = "403", description = "Forbidden"), @ApiResponse(responseCode = "404", description = "Not Found")}) default String secondEnpoint(C param) { return "secondEnpoint-ok"; } @Override @GET @Path("/original/{id}") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "400", description = "Bad Request"), @ApiResponse(responseCode = "403", description = "Forbidden"), @ApiResponse(responseCode = "404", description = "Not Found")}) default String originalEndpoint(C param) { return "originalEndpoint-ok"; } }
In the swagger generated :
- secondEnpoint ( Get on «/{id}) is present
- originalEndpoint ( Get on «/original/{id}») is not present
The reason I used this inheritance in interfaces is because I have multiple default implementations for same «base» interfaces. One default implementation for Jersey, and another one for Spring MVC
- frantuma6 years agoStaff
Thanks for the details, this seems to be an edge scenario which causes the endpoint to be indeed wrongly not resolved; created ticket https://github.com/swagger-api/swagger-core/issues/3149 to track this issue
- julienQc6 years agoOccasional Contributor
Ok,
Thanks !
Related Content
- 5 years ago
Recent Discussions
- 3 days ago
- 3 days ago
- 20 days ago