mirror of https://github.com/jeecgboot/jeecg-boot
Merge remote-tracking branch 'origin/master'
commit
68464109de
|
@ -1,12 +1,14 @@
|
||||||
package org.jeecg.handler.swagger;
|
package org.jeecg.handler.swagger;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import springfox.documentation.swagger.web.*;
|
import springfox.documentation.swagger.web.*;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/** 已使用knife4j-gateway支持该功能
|
/** 已使用knife4j-gateway支持该功能
|
||||||
|
@ -19,6 +21,9 @@ import java.util.List;
|
||||||
public class SwaggerResourceController {
|
public class SwaggerResourceController {
|
||||||
private MySwaggerResourceProvider swaggerResourceProvider;
|
private MySwaggerResourceProvider swaggerResourceProvider;
|
||||||
|
|
||||||
|
@Value("${knife4j.gateway.enabled:true}")
|
||||||
|
private Boolean enableSwagger;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public SwaggerResourceController(MySwaggerResourceProvider swaggerResourceProvider) {
|
public SwaggerResourceController(MySwaggerResourceProvider swaggerResourceProvider) {
|
||||||
this.swaggerResourceProvider = swaggerResourceProvider;
|
this.swaggerResourceProvider = swaggerResourceProvider;
|
||||||
|
@ -36,6 +41,9 @@ public class SwaggerResourceController {
|
||||||
|
|
||||||
@RequestMapping
|
@RequestMapping
|
||||||
public ResponseEntity<List<SwaggerResource>> swaggerResources() {
|
public ResponseEntity<List<SwaggerResource>> swaggerResources() {
|
||||||
|
if (!enableSwagger) {
|
||||||
|
return new ResponseEntity<>(new ArrayList<>(), HttpStatus.OK);
|
||||||
|
}
|
||||||
return new ResponseEntity<>(swaggerResourceProvider.get(), HttpStatus.OK);
|
return new ResponseEntity<>(swaggerResourceProvider.get(), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,11 +4,6 @@ server:
|
||||||
knife4j:
|
knife4j:
|
||||||
gateway:
|
gateway:
|
||||||
enabled: true
|
enabled: true
|
||||||
strategy: discover
|
|
||||||
discover:
|
|
||||||
excluded-services: ${spring.application.name}
|
|
||||||
enabled: true
|
|
||||||
version: OpenAPI3
|
|
||||||
|
|
||||||
spring:
|
spring:
|
||||||
application:
|
application:
|
||||||
|
|
Loading…
Reference in New Issue