Go最新JApiDocs与Swagger对比_japidocs和swagger,Golang面试笔试题目

10 篇文章 0 订阅
10 篇文章 0 订阅

img
img
img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上Go语言开发知识点,真正体系化!

由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新

如果你需要这些资料,可以戳这里获取

package com.hust.zhang.web.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.format.FormatterRegistry;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.validation.MessageCodesResolver;
import org.springframework.validation.Validator;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.method.support.HandlerMethodReturnValueHandler;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.config.annotation.*;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.schema.ModelRef;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

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

@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket createRestApi(){
        return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select().apis(RequestHandlerSelectors.any())
                .paths(PathSelectors.any()).build();
    }

    private ApiInfo apiInfo() {
        // springfox.documentation.service.Contact
        Contact contact = new Contact("zhang", "https://blog.csdn.net/zkkzpp258", "345921046.com");
        return new ApiInfoBuilder()
                .title("test by mr zhang")
                .description("测试swagger")
                .contact(contact)
                .version("1.0.0")
                .build();
    }
}

下面写一个简单的测试接口展示一下使用界面。

JApiDocs

官方网站:https://japidocs.agilestudio.cn/#/

虽然小伙伴们都已经习惯了使用Swagger,不过了解一下新的工具也未尝不可。毕竟听说JApiDocs是一个无需额外注解、开箱即用的SpringBoot接口文档生成工具。

依赖如下,

<dependency>
  <groupId>io.github.yedaxia</groupId>
  <artifactId>japidocs</artifactId>
  <version>1.4.2</version>
</dependency>

在test文件里去写测试文件,记得项目根目录路径一定要设置对。

    @Test
    public void test(){
        DocsConfig config = new DocsConfig();
        //root project path
        config.setProjectPath("/Users/kaizhang/workspace/hust-zhang");
        // project name
        config.setProjectName("test-japi-docs");
        // api version
        config.setApiVersion("V1.0.0");
        // api docs target path
        config.setDocsPath("/Users/kaizhang/workspace/hust-zhang/docs");
        // auto generate
        config.setAutoGenerate(Boolean.TRUE);
        // execute to generate
        Docs.buildHtmlDocs(config);
    }

最后在你设置的DocsPath里生成了html的静态页面,在静态里面可以展示最后的API文档,如下图

img
img
img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上Go语言开发知识点,真正体系化!

由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新

如果你需要这些资料,可以戳这里获取

于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新**

如果你需要这些资料,可以戳这里获取

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值