4

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

tatka
  • 301
  • 1
  • 3
  • 9
  • Of the two screenshots you shared, do you mean to say, the first is what is happening while the second is what you want? I'm a little confused as to what issue you're facing. – Debargha Roy May 24 '21 at 17:18
  • I want so that second screenshot opens by default, when I open /swagger-ui/index.html – tatka May 25 '21 at 05:40

7 Answers7

2

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.

Liang Faan
  • 31
  • 2
2

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
1

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
1

This Configuration worked for me. @tatka

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

springdoc.swagger-ui.urlsPrimaryName=myGroup

Brijan Elwadhi
  • 420
  • 3
  • 6
  • 17
0

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/
Debargha Roy
  • 2,320
  • 1
  • 15
  • 34
0

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

https://github.com/springdoc/springdoc-openapi-demos/blob/master/springdoc-openapi-spring-boot-2-webmvc/src/main/resources/application.yml

jdsthlm
  • 51
  • 5
0

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.

Alex Cumarav
  • 537
  • 5
  • 7