0

Gradle:

implementation group: 'org.springdoc', name: 'springdoc-openapi-ui', version: '1.6.13'
implementation group: 'io.swagger.core.v3', name: 'swagger-annotations', version: '2.2.7'   

Properties:

springdoc.swagger-ui.enabled=true
springdoc.swagger-ui.path=/swagger-ui.html  

Controller:

@RestController

    @RequestMapping("/api/v1/cheque")
    @FieldDefaults(level = AccessLevel.PRIVATE,makeFinal = true)
    public class ChequeController {
    
        ProductService productService;
    
        public ChequeController(ProductService productService) {
            this.productService = productService;
        }
    
        @GetMapping(value = "/get/{id}", produces = "application/json")
        public Optional<Product> getByid(@PathVariable Long id) {
            return productService.getById(id);
        }
    
        @GetMapping("/test")
        public String test() {
            return "test";
        }
    }  

Conf:

@Configuration
public class OpenApiConfiguration {

    @Bean
    public OpenAPI customOpenAPI() {
        return new OpenAPI()
                .info(
                        new Info()
                                .title("Example Swagger Api")
                                .version("1.0.0")
                );
    }
}

Trying to open in localhost:8080/swagger-ui.html and getting:

Whitelabel Error Page There was an unexpected error (type=Not Found, status=404). in https://springdoc.org/#getting-started saying, that it will automatically deploy swagger-ui to a spring-boot application
what im doing wrong

invzbl3
  • 5,872
  • 9
  • 36
  • 76
стасевич
  • 298
  • 2
  • 10

1 Answers1

0

For swagger v3+, the swagger ui default access is now swagger-ui/ instead of swagger-ui.html You should be able to access by amending your url to localhost:8080/swagger-ui/

h3y
  • 11
  • 3