api_docs shows content but swagger-ui (2.6.1) is empty
See original GitHub issueHi this is a question on configuration. I was reading for hours today but did not get my mistake.
Symptom:
http://localhost:8080/sabi/api/v2/api-docs/ shows me that the annotations have been scanned and assembled. I get a detailed json containing my content.
However when calling the swagger-ui http://localhost:8080/sabi/swagger-ui.html The ui renders, but I can see non of my API. Even by pasting the api-docs url from above and pressing enter did not lead to any result.
Here’s my setup:
Im using:
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.6.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.6.1</version>
<scope>compile</scope>
</dependency>
with spring-webmvc (4.2.1-RELEASE) and using xml-free annotation based config:
@Configuration
@EnableWebMvc
@EnableSwagger2
@ComponentScan(basePackages = "de.bluewhale.sabi")
@PropertySource("classpath:server.properties")
public class AppConfig {
@Autowired
Environment env;
@Bean
public EncryptionService encryptionService() {
return new EncryptionService(env.getProperty("accessToken.salt"), env.getProperty("accessToken.password"));
}
@Bean
public static PropertySourcesPlaceholderConfigurer properties() {
return new PropertySourcesPlaceholderConfigurer();
}
}
and
@Configuration
public class ApiDocumentationConfiguration {
@Bean
public Docket documentation() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
// .paths(regex("/api/*"))
.build()
.pathMapping("/api")
.apiInfo(metadata());
}
private ApiInfo metadata() {
return new ApiInfoBuilder()
.title("sabi's REST API documentation")
.description("see https://github.com/StefanSchubert/sabi")
.version("1.0")
.license("MIT Licence (MIT)")
.licenseUrl("https://github.com/StefanSchubert/sabi/blob/master/LICENSE")
.contact("Stefan.Schubert@bluewhale.de")
.build();
}
}
What am I doing wrong?
Issue Analytics
- State:
- Created 7 years ago
- Comments:42 (15 by maintainers)
Top Results From Across the Web
Swagger-ui.html is giving blank page - Stack Overflow
I am using url https://localhost:8080/context-path/swagger-ui/ I am able to get the JSON data for url https://localhost:8080/context-path/v2/api ...
Read more >Springfox Reference Documentation - GitHub Pages
Springfox works by examining an application, once, at runtime to infer API semantics based on spring configurations, class structure and various ...
Read more >docs/release-notes.md · serv/springfox - Gitee.com
... api_docs shows content but swagger-ui (2.6.1) is empty @StefanSchubert; (#1613) HTML code in API description in ignored using springfox-swagger-ui 2.6.1 ...
Read more >F.A.Q - Springdoc-openapi
springdoc.swagger-ui.path= /swagger-ui/api-docs.html ... It is be possible to handle as return an empty content as response using, one of the following ...
Read more >Spring Boot RESTful API Documentation with Swagger 2
Swagger 2 is a very popular tool set for documenting RESTful interfaces developed with Spring Boot. In this post I show you how...
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
Finally it’s working for me too. I needed to throw “api” as pathMapping of the docket config:
Also I have api as part of the base path of my controllers:
But the most important thing to do was this in my app-config:
Our Spring (but not spring-boot) app uses the @ annotation EnableWebMvc. To make swagger work we add a config class: