swagger-gradle-plugin
swagger-gradle-plugin copied to clipboard
Generate swagger file from annotated interfaces
Hi, is that possible to plugin work with annotated interfaces instead of concrete spring RestController class? In Spring Boot 2.1.0 project I want to separate interface from implementation, in my case, BookController. So I created an interface IBookController and put on it all swagger/spring-web annotations. However, when I try to generate the swagger file (run gradle generateSwaggerDocumentation) it seems to ignore spring annotations (for example @RequestParam String filter in getBooks method).
https://github.com/PiotrDros/SpringSwagger/tree/feature/separate_interfaces/spring-swagger
Hi, Same question for me, thanks!!
Looks like in SpringMvcApiReader
this is the culprit:
Set<Class<?>> getValidClasses() {
Set<Class<?>> classes = Sets.union(classFinder.getValidClasses(Api, apiSource.locations), classFinder.getValidClasses(RestController, apiSource.locations))
Set<Class<?>> copied = new HashSet<>(classes)
for (Class<?> clazz : classes) {
for (Class<?> aClazz : classes) {
if (clazz != aClazz && clazz.isAssignableFrom(aClazz)) {
copied.remove(clazz)
}
}
}
copied
}
My initial guess (without having debugged it) would be that it's picking up the lower classes and only using those. Of course I could be way off the mark on that though.