美文网首页开发中的小问题解决
Swagger中byte为什么自动转成了string,解决方案

Swagger中byte为什么自动转成了string,解决方案

作者: eagle隼 | 来源:发表于2018-03-28 17:07 被阅读0次

在用实体类做参数时,model里byte类型的参数在swagger页面model里

竟然自动变成了string类型

苦搜方法无果只能查看官方文档 https://springfox.github.io/springfox/docs/current/

从里面的第9条配置找到的解决方案

@Bean
public Docket createRestApi() {
    return new Docket(DocumentationType.SWAGGER_2)
            .apiInfo(apiInfo())
            //修正Byte转string的Bug
            .directModelSubstitute(Byte.class, Integer.class)
            .select()
            // 指定controller存放的目录路径
            .apis(RequestHandlerSelectors.basePackage(""))
            .paths(PathSelectors.any())
            .build();
}

相关文章

网友评论

    本文标题:Swagger中byte为什么自动转成了string,解决方案

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