공부
[Spring Boot] How to fully disable swagger-ui in spring-boot?(/swagger-ui.html should return 404)
승가비
2022. 1. 12. 13:38
728x90
@Profile(value = {"swagger"})
@Configuration
@EnableSwagger2
public class SwaggerConfiguration {
...
}
import org.apache.commons.lang3.StringUtils;
import org.springframework.context.annotation.Profile;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
@Profile("!local")
@Controller
public class SwaggerUiController {
@GetMapping(value = "swagger-ui.html")
public ResponseEntity disable() {
return new ResponseEntity<>(StringUtils.EMPTY, HttpStatus.NOT_FOUND);
}
}
How to fully disable swagger-ui in spring-boot?(/swagger-ui.html should return 404)
I have read following topic: Disabling Swagger with Spring MVC and I wrote: @Bean public Docket api() { return new Docket(DocumentationType.SWAGGER_2) .select() .apis(
stackoverflow.com
728x90