接口文档生成器

2020-06-08

Swagger3

结合Spring Boot快速开发

pom.xml

<!-- https://mvnrepository.com/artifact/io.springfox/springfox-boot-starter -->
<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-boot-starter</artifactId>
    <version>3.0.0</version>
</dependency>

SwaggerConfig.java

/**
 * 类说明: Swagger3配置文件
 *
 * @author : Malu
 * @Since : 2020-08-31 17:49
 **/
@Configuration
@EnableSwagger2
public class SwaggerConfig {
    @Bean
    public Docket customDocket() {
        return new Docket(DocumentationType.OAS_30)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.bric.datacloud.dataway.controller")) //Selection by RequestHandler
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("应用接口")
                .description("欢迎访问")
                .contact(new Contact("malu", "http://malu.me", "malu@malu.me"))
                .version("1.0")
                .build();
    }
}

Swagger2

<!-- swagger2 -->
<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger2</artifactId>
    <version>${swagger.version}</version>
</dependency>
<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger-ui</artifactId>
    <version>${swagger.version}</version>
</dependency>

knife4j

是为Java MVC框架集成Swagger生成Api文档的增强解决方案

https://gitee.com/xiaoym/knife4j

demo代码

https://gitee.com/xiaoym/swagger-bootstrap-ui-demo

japidocs

无需额外注解的 SpringBoot API文档生成工具

https://japidocs.agilestudio.cn/

docgen

可以将Postman导出的json集合转化为HTML/Markdown文档

https://github.com/thedevsaddam/docgen

要查看邮递员收藏的实时HTML文档,请使用docgen server -f input-postman-collection.json -p 8000它将打开邮递员收藏的html版本到定义的端口
要查看邮递员收藏的实时Markown文档,请使用docgen server -f input-postman-collection.json -p 8000 -m它将邮递员收藏的markdown版本打开到定义的端口
要使用HTML文档 docgen build -i input-postman-collection.json -o ~/Downloads/index.html
制作Markdown文档 docgen build -i input-postman-collection.json -o ~/Downloads/index.md -m

oracle接口文档编辑器

https://app.apiary.io/apitest261/editor