Swagger提示请确保swagger资源接口正确

问题描述

在项目开发过程中集成swagger-bootstrap-ui,打开swagger-ui.html页面正常,但是打开doc.html页面提示"请确保swagger资源接口正确"。


原因分析:

原因是JSON格式非法,一般出现此情况时,是因为后端在给属性赋予了exmpale属性时,赋值了json字符串导致。

比如:

@ApiModelProperty(value = "客户字段数据",example = "{'id':'xxx'}")
private List<String> fields;

@ApiModelProperty(value = "参数数据",example = "{'name':'xxx'}")
private String param;

解决方案:

把属性中的example去掉,或者把单引号替换成转义后的双引号

@ApiModelProperty(value = "客户字段数据",example = "{\"id\":\"xxx\"}")
private List<String> fields;

@ApiModelProperty(value = "参数数据",example = "{\"name\":\"xxx\"}")
private String param;

相关推荐

  1. Swagger提示确保swagger资源接口正确

    2023-12-09 05:34:08       62 阅读
  2. <span style='color:red;'>Swagger</span>

    Swagger

    2023-12-09 05:34:08      37 阅读
  3. Swagger PHP Thinkphp 接口文档

    2023-12-09 05:34:08       67 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2023-12-09 05:34:08       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2023-12-09 05:34:08       100 阅读
  3. 在Django里面运行非项目文件

    2023-12-09 05:34:08       82 阅读
  4. Python语言-面向对象

    2023-12-09 05:34:08       91 阅读

热门阅读

  1. http和https区别

    2023-12-09 05:34:08       58 阅读
  2. TCP通讯

    TCP通讯

    2023-12-09 05:34:08      52 阅读
  3. Golang优雅实现按比例切分流量

    2023-12-09 05:34:08       55 阅读
  4. 数据库基础概念与范式反范式总结

    2023-12-09 05:34:08       53 阅读
  5. C++基础

    C++基础

    2023-12-09 05:34:08      43 阅读
  6. 初识主力投资者

    2023-12-09 05:34:08       54 阅读