فهرست منبع

swagger 根据配置是否显示

gaodm 5 سال پیش
والد
کامیت
84a0a8665a

+ 2 - 0
gateway-service/src/main/java/com/diagbot/config/swagger/SwaggerProvider.java

@@ -1,6 +1,7 @@
 package com.diagbot.config.swagger;
 
 import lombok.AllArgsConstructor;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.cloud.gateway.config.GatewayProperties;
 import org.springframework.cloud.gateway.route.RouteLocator;
 import org.springframework.cloud.gateway.support.NameUtils;
@@ -20,6 +21,7 @@ import java.util.List;
 @Component
 @Primary
 @AllArgsConstructor
+@ConditionalOnProperty(prefix = "swagger", value = { "enable" }, havingValue = "true")
 public class SwaggerProvider implements SwaggerResourcesProvider {
     public static final String API_URI = "/v2/api-docs";
     private final RouteLocator routeLocator;

+ 2 - 0
gateway-service/src/main/java/com/diagbot/handler/SwaggerHandler.java

@@ -1,6 +1,7 @@
 package com.diagbot.handler;
 
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -17,6 +18,7 @@ import java.util.Optional;
 
 @RestController
 @RequestMapping("/swagger-resources")
+@ConditionalOnProperty(prefix = "swagger", value = { "enable" }, havingValue = "true")
 public class SwaggerHandler {
     @Autowired(required = false)
     private SecurityConfiguration securityConfiguration;