Swagger报错:missed comma between flow collection entries

控制台warn提示 Illegal DefaultValue null for parameter type integer java
出现这个问题主要是使用了 ApiModelProperty 注解修饰了非 String 类型的变量,而此时,example 未赋值造成。

@ApiModelProperty(value = "用户 id", dataType = "int", example = "1")
private int id;

上面这种写法就不会报警告了。

除了上面这种方式,还可以使用如下配置避免看到 warn 的警告:

logging.level.io.swagger.models.parameters.AbstractSerializableParameter=error

PS:example 的值不是简单的示例值简单,你不能不符合数据格式的随便写写:

   @ApiModelProperty(notes = "返回数据内容", required = true, example = "[{}...{}]")
    private T data;

上面这种写法,会报错误,swagger都无法正常预览接口。

公众号-JavaEdge CSDN认证博客专家 CSDN博客专家 慕课网认证作者 腾讯云+最佳作者
1.经历:19届双一流本科,曾在百度、携程、华为等大厂搬金砖
2.涉猎领域:Java生态各种中间件原理、框架源码、微服务、中台等架构设计及落地实战,只生产硬核干货!
3.开源社区荣誉:阿里云栖社区博客专家、腾讯云+社区2019年度最佳作者、慕课网认证作者、CSDN百万流量万粉博客专家,简书优秀创作者兼《程序员》专题管理员
4.著作:在牛客网著有《Java源码面试解析指南》,目前已有上千人在学习,已助众多读者成功拿到满意offer~
已标记关键词 清除标记
<div><p>Example value make parse failed. It works fine in 2.7.0.</p> <p>The error message in swagger-ui:</p> <pre><code> Errors Parser error missed comma between flow collection entries </code></pre> <p>The error in browser console:</p> <p>r mark : r {name: null, buffer: "{"swagger":"2.0","info":{"description":"Api Docume…cription":"The username"}},"title":"UserDto"}}}↵", position: 30173, line: 0, column: 30173} message : "missed comma between flow collection entries at line 1, column 30174:↵ ... type":"string","example":[test] n/a,"description":"The username" ... ↵ ^" name : "YAMLException" reason : "missed comma between flow collection entries"</p> <p>The Java code:</p> <pre><code>Java (value = "The username", example = "[test] n/a") private String name; </code></pre> <p>Please take the time to search the repository, if your question has already been asked or answered.</p> <ul><li> <p>[x] What version of the library are you using? Is it the latest version? The latest released version is <a href="https://bintray.com/springfox/maven-repo/springfox/_latestVersion"> <img alt="Download" src="https://api.bintray.com/packages/springfox/maven-repo/springfox/images/download.svg" /> </a> 2.9.0 What kind of issue is this?</p> </li><li> <p>[ ] Question. Is this a question about how to do a certain thing? </p> </li><li> <p>[x] Bug report. If you’ve found a bug, spend the time to write a failing test. Bugs with tests or steps to reproduce get fixed faster. Here’s an example: https://gist.github.com/swankjesse/6608b4713ad80988cdc9</p> <ul><li>[ ] spring xml/java config that is relevant</li><li>[ ] springfox specific configuration if it makes sense</li><li>[ ] include any output you've received; logs, json snippets etc.; and what the expected output should be</li><li>[ ] if you have a repo that demonstrates the issue for bonus points! See <a href="https://github.com/springfox/springfox/issues/494">this example</a> </li></ul> </li><li> <p>[ ] Feature Request. Start by telling us what problem you’re trying to solve. Often a solution already exists! Don’t send pull requests to implement new features without first getting our support. Sometimes we leave features out on purpose to keep the project small.</p> </li></ul> <p>Please do consider <strong><em>starring</em></strong> this repository if you do like this project and find it useful. </p><p>该提问来源于开源项目:springfox/springfox</p></div>
©️2020 CSDN 皮肤主题: 黑客帝国 设计师:白松林 返回首页