'spring boot - springdoc open api: No api definiation provided error
I need to document my spring boot application's rest apis with SpringDoc OpenApi. So, I added this dependency in my pom.xml:
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.6.8</version>
</dependency>
And here is my config class:
@Configuration
public class SwaggerConfig {
@Bean
public GroupedOpenApi apis() {
return GroupedOpenApi.builder()
.group("my-application")
.packagesToScan("com.myapp.base")
.pathsToMatch("/**")
.build();
}
}
When I want to use swagger-ui in /base-url/swagger-ui/index.html
, the result is as below image:
What's wrong in my configuration?
I use spring boot 2.6.6.
Note: I don't see any problem to load swagger resources in browser console(401, 404). Also I have disabled spring security in app, there is not any problem related to security or loading swagger resources.
Solution 1:[1]
You bean looks okay to me but you're probably not hitting the right endpoint for the Swagger-UI.
The URL /base-url/swagger-ui/index.html
points to the Swagger-UI provided by the Swagger Core library and there's not a lot you can do about it.
Springdoc has a transitive dependency on Swagger Core and as such the page is available. But the URL at which Springdoc exposes it's Swagger-UI is /base-url/swagger-ui.html
.
Refer to the answer here for an explanation on why is it so and the ways to update it.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Debargha Roy |