Swagger-Ui not showing any controller even though api-docs are there
See original GitHub issueI’m trying to make a single REST controller integrated with Springfox using only Java Based configuration.
The json is being generated correctly so Swagger UI should display the doc as well, but this is not happening, the UI is shown as well but with no documentation in it.
I’m using Springfox 2.5.0 Here are the main parts of the configuration: Swagger Configuration
@EnableSwagger2
public class ConfigSwagger {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("Información")
.build();
}
}
MVC configuration
@EnableWebMvc
@Configuration
@Import(ConfigSwagger.class)
@ComponentScan(basePackages = {"confbase"})
public class MvcConfig extends WebMvcConfigurerAdapter{
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
registry.addResourceHandler("swagger-ui.html")
.addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/");
}
@Override
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
configurer.enable();
}
}
WebAppInitializer
@Configuration
public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
@Override
protected Class<?>[] getRootConfigClasses() {
return new Class[] { MvcConfig.class, ConfigSwagger.class };
}
@Override
protected Class<?>[] getServletConfigClasses() {
return null;
}
@Override
protected String[] getServletMappings() {
return new String[] { "/api/*" };
}
}
The Controller
@Controller
@RestController
public class AController {
@RequestMapping(method = RequestMethod.GET, value = "/string")
public String getString() {
return "String";
}
}
They’re all in the same package.
I don’t know what the problem could be. Thanks in advanced for any help you could give!
Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (2 by maintainers)
Top Results From Across the Web
Controller does not appear in swagger-ui.html - Stack Overflow
It happened to me that one of the controllers was not displayed. The problem was the kotlin class has not declared any package....
Read more >Solved: Adding New Controllers Not Showing in UI
I believe the issue was that inside the controller, the name of the class didn't in with the word "Controller". It ended with...
Read more >swagger UI not rendering some of the controllers in the api ...
I'm using springfox-swagger-ui:2.3.1 with springfox-swagger2:2.3.1 in spring boot web application. all of my @RestController are identified ...
Read more >Show only specific APIs on Swagger — Asp.Net Core - Medium
In this article, I explain how to use Document Filters on Swagger in order to control the endpoints that are being shown on...
Read more >Setting Up Swagger 2 with a Spring REST API - Baeldung
Now if we refresh the Swagger documentation, we see custom-controller in the list of controllers. As we know, there is only one method...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Would you mind trying with 2.6.1?
Also since your servlet is looking for apis at
/api/*
you might have to play around with your configuration a bit. Try changing that to/
and work yourself up to/api
Do you min sharing your project?
Sent from my iRotary phone
On Mar 28, 2020, at 4:48 PM, syeddanishzakir8080 notifications@github.com wrote:
I’m facing the same issue. Even though I have added the swagger-ui but I can’t still figure out why the ui is getting 404.
— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/springfox/springfox/issues/1688#issuecomment-605517649, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACO7FDMCIR2DLOSNNTS7ODLRJZO75ANCNFSM4DBEJ2YQ.