美文网首页
使用swagger2生成在线接口文档

使用swagger2生成在线接口文档

作者: 青柠_efca | 来源:发表于2019-04-17 20:19 被阅读0次

swagger生态图

image

swagger UI 使用方法

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

  • 在应用主类中增加@EnableSwagger2Doc注解
@SpringBootApplication
@EnableSwagger2Doc
public class Springboot2Swagger2Application {

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

默认情况下就能产生所有当前SpringMVC加载的请求映射文档

访问地址:http://localhost:8080/swagger-ui.html

  • 参数配置示例
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=https://www.jianshu.com/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

相关文章

网友评论

      本文标题:使用swagger2生成在线接口文档

      本文链接:https://www.haomeiwen.com/subject/qgsowqtx.html