'How set default API definition url in openapi?
I want set default scheme by url /v3/api-docs/, but there are empty url and error "No API definition provided.".
Which settings properties I should use?
Current code in project:
application.properties
springdoc.swagger-ui.disable-swagger-default-url=true
springdoc.swagger-ui.use-root-path=true
SwaggerConfig.java
@Configuration
public class SwaggerConfig {
@Bean
public GroupedOpenApi applicationApi() {
String packagesToScan[] = {"ru.vetrf.ecert.web.application"};
return GroupedOpenApi.builder()
.group("application")
.pathsToMatch("/rest-api/application/**")
.packagesToScan(packagesToScan)
.build();
}
@Bean
public OpenAPI eCertOpenAPI() {
return new OpenAPI()
.info(new Info().title("ECert API")
.description("ECert API")
.version("v1.0.0"))
;
}
}
pom.xml
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.5.9</version>
</dependency>
Solution 1:[1]
With the latest version of springdoc-openapi-ui for me, it was 1.6.7
I updated my spring boot application config YAML to the following and it worked:
springdoc:
swagger-ui:
config-url: /v3/api-docs/swagger-config
disable-swagger-default-url: true
url: /v3/api-docs
Solution 2:[2]
Tried reproducing the same but the current set of properties that you're using works fine for me.
Hopefully adding the below property to your application.properties should help
springdoc.swagger-ui.configUrl=/v3/api-docs/
Solution 3:[3]
This property seems to use the springdoc.swagger-ui.config_url path:
springdoc.swagger-ui.use-root-path=true
This property seems to say, use config_url path as root path in explore field in swagger-ui.
I found the solution in looking in the demo repository for spring-doc openapi
Solution 4:[4]
For all upgrade to swagger-ui 4.1.3, pls check below:
https://github.com/swagger-api/swagger-ui/releases/tag/v4.1.3
Note: to re-enable the functionality of reading config params from URL, set new queryConfigEnabled core parameter to true. More info in documentation.
Solution 5:[5]
I had the same problem, and it worked for me this way
springdoc:
swagger-ui:
query-config-enabled: true
api-docs:
path: /my-service/v3/api-docs
testing some properties, I found that this parameter does the magic :)
query-config-enabled: true
Solution 6:[6]
I had a similar problem, all properties have been set correctly but the default value in the Explore Text Field was empty, and No API definition provided. was rendered. Update of springdoc-openapi-ui from 1.5. to 1.6 has solved the problem.
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 | Test Salapet |
| Solution 2 | Debargha Roy |
| Solution 3 | jdsthlm |
| Solution 4 | Liang Faan |
| Solution 5 | Lucas Silva |
| Solution 6 | Alex Cumarav |


