使用swagger2生成在線接口文檔

swagger生態(tài)圖

image

swagger UI 使用方法

  • 在pom.xml中引入依賴
   <dependency>
      <groupId>com.spring4all</groupId>
        <artifactId>swagger-spring-boot-starter</artifactId>
        <version>1.8.0.RELEASE</version>
      </dependency>

  • 在應(yīng)用主類中增加@EnableSwagger2Doc注解
@SpringBootApplication
@EnableSwagger2Doc
public class Springboot2Swagger2Application {

    public static void main(String[] args) {
        SpringApplication.run(Springboot2Swagger2Application.class, args);
    }
}

默認情況下就能產(chǎn)生所有當(dāng)前SpringMVC加載的請求映射文檔

訪問地址:http://localhost:8080/swagger-ui.html

  • 參數(shù)配置示例
swagger.enabled=true
swagger.title=spring-data-jpa module
swagger.description=Starter for swagger 2.x
swagger.license=Apache License, Version 2.0
swagger.licenseUrl=https://www.apache.org/licenses/LICENSE-2.0.html
swagger.termsOfServiceUrl=https://github.com/dyc87112/spring-boot-starter-swagger
swagger.contact.name=mqXu
swagger.contact.url=http://www.itdecent.cn/u/822585e5c69a
swagger.contact.email=moqi1977@gmail.com
swagger.base-package=com.springboot.mybatis.controller
swagger.base-path=/**
swagger.exclude-path=/error, /ops/**

swagger UI整體效果

image
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容