No API definition provided. - openApi - springdoc

3.5k views Asked by At

I have a simple boot application where I have added open api swagger dependency

springdoc-openapi-ui

along with these properties

springdoc.swagger-ui.disable-swagger-default-url=true
springdoc.swagger-ui.configUrl=/v3/api-docs/swagger-config
springdoc.swagger-ui.path=/swagger-ui.html

I am getting these error (when calling http://localhost:8080/swagger-ui/index.html):

No API definition provided.

this is my controller :

@RestController
public class HelloWorld {

@GetMapping("sayHi")
public String sayHi(){
    return "Hi Beno";
}
}

Any idea ?

1

There are 1 answers

0
Debargha Roy On

When using a different endpoint to serve the OpenAPI Config, you'll need to set two properties

// This will set UI to fetch the config's URL from "somePath"
springdoc.swagger-ui.configUrl=somePath

// You also need to serve the config file from the endpoint at "somePath"
springdoc.api-docs.path=somePath