生活随笔
收集整理的這篇文章主要介紹了
swagger配置分组
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
在實際生產環境中,為了方便接口對應各自的開發人員,可以分組也即定義多個Docket對象
package com
.yk
.config
;import org
.springframework
.context
.annotation
.Bean
;
import org
.springframework
.context
.annotation
.Configuration
;
import springfox
.documentation
.builders
.RequestHandlerSelectors
;
import springfox
.documentation
.oas
.annotations
.EnableOpenApi
;
import springfox
.documentation
.service
.ApiInfo
;
import springfox
.documentation
.service
.Contact
;
import springfox
.documentation
.spi
.DocumentationType
;
import springfox
.documentation
.spring
.web
.plugins
.Docket
;import java
.util
.ArrayList
;
import java
.util
.function
.Predicate
;@Configuration
@EnableOpenApi
public class SwaggerConfig {@Beanpublic Docket
docket(){return new Docket(DocumentationType
.OAS_30
).apiInfo(apiInfo()).groupName("就業組").select().apis(RequestHandlerSelectors
.basePackage("com.yk.controller.user")).build();}@Beanpublic Docket
docket2(){return new Docket(DocumentationType
.OAS_30
).apiInfo(apiInfo()).groupName("醫療組").select().apis(RequestHandlerSelectors
.basePackage("com.yk.controller.medicine")).build();}public ApiInfo
apiInfo(){return new ApiInfo("Swagger運用","第一次使用需要注意!!","1.0","https://blog.csdn.net/weixin_42374693",new Contact("ykjcce","https://github.com/ykconvert","963692139@qq.com"), "Apache 2.0","http://www.apache.org/licenses/LICENSE-2.0",new ArrayList<>());}
}
注 在新版的Swagger中,由于依賴導入的是啟動器我們可以在配置文件application.yml中直接定義是否開啟Swagger的相關功能。如下
springfox
:documentation
:enabled
: true
總結
以上是生活随笔為你收集整理的swagger配置分组的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。