1 Star 3 Fork 0

DDD / slash-doc

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

简介

基于knife4j,swagger增强处理

使用方法

依赖


<dependency>
    <groupId>site.lanmushan</groupId>
    <artifactId>slash-doc-starter</artifactId>
    <version>1.0.4</version>
</dependency>

配置文件

##sw兼容版本配置
spring:
  mvc:
    pathmatch:
      matching-strategy: ant_path_matcher
debug: false
##配置开启关闭
slashdoc:
  enabled: true
  enhance: true
  title: 测试文档

增强内容

springmvc增强

直接在PostMapping,GetMapping写入name名称即可,省去原来的@ApiOperation注解,如果写了取原始的名称

   @PostMapping(name = "测试测试", value = "/test")
public void PostMappingSaveGroup(@RequestBody SysTbApp sysTbApp,@RequestParam String test){
        return;
        }

@Validated和@Valid校验增强,

根据方法中@Validated和@Valid的注解,判断实体类内部相关校验注解

    @PostMapping(name = "Validated分组测试UpdateGroup", value = "/PostMappingUpdateGroup")
    public void PostMappingUpdateGroup(@RequestBody @Validated(UpdateGroup.class)
                                               SysTbApp sysTbApp, @RequestParam String test) {
        return;
    }

    @PostMapping(name = "Valid测试", value = "/PostMappingValid")
    public void PostMapping3(@RequestBody @Valid SysTbApp sysTbApp, @RequestParam String test) {
        return;
    }

字典映射增强

在属性上增加 @ApiModelEnumMapping注解,可将枚举值直接映射到doc中

@Data
@ApiModel
public class SysTbApp {
    private String appWebUrl;
    @ApiModelProperty(value = "接口地址")
    private String appApiUrl;
    @ApiModelProperty(value = "启用状态", required = true)
    @ApiModelEnumMapping(value = EnabledEnum.class)
    private Integer enabled;
    @ApiModelProperty(value = "字典")
    private SysTbDict tbDict;
    @ApiModelProperty("测试范围")
    @Min(value = 10)
    private Integer aaa;
}
package site.lanmushan.slashdocdemo.enums;

import site.lanmushan.slashdocstarter.api.ApiMapping;
import site.lanmushan.slashdocstarter.api.ApiModelEnumMappingProvider;

import java.util.ArrayList;
import java.util.List;

/**
 * @author dy
 */

public enum EnabledEnum implements ApiModelEnumMappingProvider {
    /**
     * 测试
     */
    enable(1, "启用"),
    disabled(0, "禁用");
    private int type;
    private String value;

    EnabledEnum(int s, String s1) {
        this.type = s;
        this.value = s1;
    }

    public int getType() {
        return type;
    }

    public String getValue() {
        return value;
    }

    @Override
    public List<ApiMapping> readMapping() {
        EnabledEnum[] enabledEnums = EnabledEnum.values();
        List<ApiMapping> arrList = new ArrayList<>();
        for (int i = 0; i < enabledEnums.length; i++) {
            EnabledEnum userTypeEnum = enabledEnums[i];
            arrList.add(new ApiMapping(userTypeEnum.type, userTypeEnum.value));
        }
        return arrList;
    }
}
MIT License Copyright (c) 2022 daiyu Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

基于knife4j,swagger增强处理 展开 收起
Java
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/lanmushan/slash-doc.git
git@gitee.com:lanmushan/slash-doc.git
lanmushan
slash-doc
slash-doc
1.0.x

搜索帮助