swagger2如何進(jìn)行接口排序

項(xiàng)目中使用的是springboot2.0+swagger2作為接口文檔。遇到一個問題,如何對接口做排序讓看接口的更直觀些呢。

在marven中增加
<!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 -->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.9.2</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.github.xiaoymin/swagger-bootstrap-ui -->
        <dependency>
            <groupId>com.github.xiaoymin</groupId>
            <artifactId>swagger-bootstrap-ui</artifactId>
            <version>1.9.6</version>
        </dependency>
https://www.cnblogs.com/mydotnetforyou/p/11943252.html
關(guān)鍵一點(diǎn)swagger注解的使用
@ApiSort(value = 5):給接口排序
@ApiOperationSupport(order = 1):給接口里面的方法排序,如下:
@RestController
@RequestMapping(value = "/api/message")
@Api(tags = "接口-短信")
@ApiSort(value = 5)
@ApiIgnore()
public class MessageController {


    @RequestMapping(value = "/ct", method = {RequestMethod.GET}, produces = {"application/json"})
    @ApiOperation(value = "短信總數(shù)", notes = "獲取短信總數(shù)")
    @ApiOperationSupport(order = 1)
    public Result CT() {
      ...
    }
在接口上寫上@ApiSort  @ApiOperationSupport代表接口排序,
在原EnableSwagger2注解上增加@EnableSwaggerBootstrapUi注解
@Configuration
@EnableSwagger2
@EnableSwaggerBootstrapUI
public class SwaggerConfiguration {
    //more...   
}
image.png

不想接口在頁面上顯示可以使用注解@ApiIgnore()

如何使用增強(qiáng)功能


image.png

image.png

相關(guān)參考文章:swagger-bootstrap-ui 1.8.5 發(fā)布,Swagger增強(qiáng)UI實(shí)現(xiàn)
springboot+swagger2 如何給接口排序
http://localhost:8091/doc.html 查看本地swaggerui文檔localhost:8091是項(xiàng)目地址
http://localhost:8091/swagger-ui.html 查看接口文檔
https://github.com/xiaoymin/swagger-bootstrap-ui.git git地址

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容

  • 今天技術(shù)總監(jiān)說:小明,我們本次3.0改造,使用swagger2.0作為前后端分離的接口規(guī)范,它可以一鍵生成前后端的...
    coder小明閱讀 3,418評論 4 12
  • 前言 前端經(jīng)常抱怨后端給的接口文檔與實(shí)際情況不一致。 后端又覺得編寫及維護(hù)接口文檔會耗費(fèi)不少精力,經(jīng)常來不及更新。...
    JTravler閱讀 536評論 0 0
  • Swagger為我們提供了一套通過代碼和注解自動生成文檔的方法。 1.Swagger簡介 Swagger 是一套基...
    Yanl__閱讀 310評論 0 0
  • 本文屬于原創(chuàng),轉(zhuǎn)載注明出處,歡迎關(guān)注微信小程序小白AI博客 微信公眾號小白AI或者網(wǎng)站 https://xiaob...
    小白AI閱讀 585評論 0 4
  • 今日打卡2:共計(jì)55分鐘 相信自己處理問題和解決困難的能力 投資要注意控制風(fēng)險(xiǎn) 相信復(fù)利的魔力 賬面上的盈虧有時候...
    吟_f3da閱讀 253評論 0 0