Swagger 不解析 @XmlElementWrapper 注释 [英] Swagger does not parse @XmlElementWrapper annotation
本文介绍了Swagger 不解析 @XmlElementWrapper 注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 Swagger 为我的基于 jax-rs 的 API 生成文档.在我的一个模型中,我具有以下属性:
I'm using Swagger to generate documentation for my jax-rs based API. In one of my models I have the following property:
@XmlElementWrapper(name = "clip_list")
@XmlElement(name = "clip")
public List<Clip> mClips = new ArrayList<Clip>();
但是在 UI 中生成的 JSON 模型如下:
However the JSON model generated in the UI is as follows:
"clip": [
{
"duration":"",
"url":"",
"thumb":"",
}
]
所以很明显 XmlElementWrapper 注释没有被解析.如何强制 Swagger 正确嵌套元素?
So obviously the XmlElementWrapper annotation is not parsed. How can I force Swagger to correctly nest elements?
输出应该是这样的:
"clip_list": [
{
"duration":"",
"url":"",
"thumb":"",
}
]
推荐答案
解决了这个问题.只需从 swagger 依赖中排除以下依赖即可.
Soved the issue. Just exclude the following dependencies from swagger dependency.
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
</exclusion>
</exclusions>
排除这些后,我能够使注释正常工作.
After excluding these i was able to get the annotations working.
这篇关于Swagger 不解析 @XmlElementWrapper 注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文