Swagger-ui.html页面简单的修改

Swagger的优点
1.号称世界上最流行的api框架
2.RestFull API文档在线自动生成工具,API文档与API定义同步更新
3.直接运行,可以测试API接口
4.支持多种语言

springboot集成Swagger
创建新的Springboot项目
相关Maven依赖jar包

<!--swagger核心jar包  swagger2  swagger-ui-->
        <!-- 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/io.springfox/springfox-swagger-ui -->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.9.2</version>
        </dependency>

核心jar包:Swgger2 和Swagger-ui

配置Swagger config

@Configuration
@EnableSwagger2  //开启Swagger2
public class SwaggerConfig {
}

运行测试
localhost:8080/swagger-ui.html
在这里插入图片描述
该页面四大部分
源码
ApiInfo 配置Swagger信息

public class ApiInfo {
   public static final Contact DEFAULT_CONTACT = new Contact("", "", "");
   public static final ApiInfo DEFAULT;
   private final String version;
   private final String title;
   private final String description;
   private final String termsOfServiceUrl;
   private final String license;
   private final String licenseUrl;
   private final Contact contact;
   private final List<VendorExtension> vendorExtensions;

   /** @deprecated */
   @Deprecated
public ApiInfo(String title, String description, String version, String termsOfServiceUrl, String contactName, String license, String licenseUrl) {
       this(title, description, version, termsOfServiceUrl, new Contact(contactName, "", ""), license, licenseUrl, new ArrayList());
   }
 public ApiInfo(String title, String description, String version, String termsOfServiceUrl, Contact contact, String license, String licenseUrl, Collection<VendorExtension> vendorExtensions) {
       this.title = title;
       this.description = description;
       this.version = version;
       this.termsOfServiceUrl = termsOfServiceUrl;
       this.contact = contact;
       this.license = license;
       this.licenseUrl = licenseUrl;
       this.vendorExtensions = Lists.newArrayList(vendorExtensions);
   }

修改swagger-ui页面Swagger核心类ApiInfo
源码:

DEFAULT = new ApiInfo("Api Documentation", "Api Documentation", "1.0", "urn:tos", DEFAULT_CONTACT, "Apache 2.0", "http://www.apache.org/licenses/LICENSE-2.0", new ArrayList());

复制修改

  //配置Swagger信息=apiInfo
   private ApiInfo apiInfo(){

       //作者信息
       Contact contact = new Contact("TheSky", "https://www.csdn.net/", "xxx@qq.com");
       return new ApiInfo("TheSky的SwaggerAPI文档",
           "Api Documentation",
           "1.0",
           "urn:tos",
           contact,
           "Apache 2.0",
           "http://www.apache.org/licenses/LICENSE-2.0",
           new ArrayList());

   }

得到
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

不脱顶的程序员小王

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值