Commit d193d2dd4a877b061809f0e2e010e8c1ba111bac
1 parent
711a39b8
spring doc:支持通过 springdoc.api-docs 禁用
Showing
2 changed files
with
5 additions
and
3 deletions
yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/swagger/config/YudaoSwaggerAutoConfiguration.java
| ... | ... | @@ -16,6 +16,7 @@ import org.springdoc.core.customizers.ServerBaseUrlCustomizer; |
| 16 | 16 | import org.springdoc.core.providers.JavadocProvider; |
| 17 | 17 | import org.springframework.boot.autoconfigure.AutoConfiguration; |
| 18 | 18 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; |
| 19 | +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | |
| 19 | 20 | import org.springframework.boot.context.properties.EnableConfigurationProperties; |
| 20 | 21 | import org.springframework.context.annotation.Bean; |
| 21 | 22 | import org.springframework.http.HttpHeaders; |
| ... | ... | @@ -39,6 +40,7 @@ import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.HEADER_ |
| 39 | 40 | @AutoConfiguration |
| 40 | 41 | @ConditionalOnClass({OpenAPI.class}) |
| 41 | 42 | @EnableConfigurationProperties(SwaggerProperties.class) |
| 43 | +@ConditionalOnProperty(prefix = "springdoc.api-docs", name = "enabled", havingValue = "true", matchIfMissing = true) // 设置为 false 时,禁用 | |
| 42 | 44 | public class YudaoSwaggerAutoConfiguration { |
| 43 | 45 | |
| 44 | 46 | // ========== 全局 OpenAPI 配置 ========== | ... | ... |
yudao-server/src/main/resources/application.yaml
| ... | ... | @@ -37,12 +37,12 @@ spring: |
| 37 | 37 | --- #################### 接口文档配置 #################### |
| 38 | 38 | |
| 39 | 39 | springdoc: |
| 40 | - swagger-ui: | |
| 41 | - enabled: true | |
| 42 | - path: /swagger-ui | |
| 43 | 40 | api-docs: |
| 44 | 41 | enabled: true |
| 45 | 42 | path: /v3/api-docs |
| 43 | + swagger-ui: | |
| 44 | + enabled: true | |
| 45 | + path: /swagger-ui | |
| 46 | 46 | |
| 47 | 47 | knife4j: |
| 48 | 48 | enable: true | ... | ... |