How set default API definition url in openapi?

Viewed 7116

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>

enter image description here

enter image description here

7 Answers

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

This Configuration worked for me. @tatka

springdoc.swagger-ui.disable-swagger-default-url=true

springdoc.swagger-ui.urlsPrimaryName=myGroup

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/

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

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.

Related