在WF9上使用jettison + swagger进行RESTEasy

时间:2015-07-25 14:34:12

标签: wildfly swagger resteasy atom-feed jettison

我们正在使用RESTEasy与jettison提供商(不是杰克逊,因为它不支持我们真正喜欢的Atom链接)并尝试使用Swagger创建有效的API文档。然而,jettison使用" xmlRootElement"生成json,而swagger假设" normal&#34 ;, jackson-like json。因此,生成的文档无效,使用swagger客户端生成器生成的客户端无效。例如:

Java类:


    @Mapped(namespaceMap = @XmlNsMap(jsonName = "atom", namespace =     "http://www.w3.org/2005/Atom"))
    @ApiModel(value = "Service", description = "Service resource representation")
    @XmlRootElement
    @XmlAccessorType(XmlAccessType.NONE)
    public class Service {

    @XmlID
    @XmlAttribute(name = "id")
    @ApiModelProperty(value = "Service's unique id")
    private String id;

    @XmlAttribute(name = "fullName")
    @ApiModelProperty(value = "Service's full name")
    private String fullName;

    @XmlElementRef
    protected RESTServiceDiscovery rest;

    //getters and setters
    ....
    }
   

Swagger生成的模型:

{  "id": "string",   "fullName": "string"}

来自服务器的响应

{  "service": {  "id": "xyz", "fullName": "Example full name"}}

有没有办法让招摇和抛弃合作?我们真的不想将提供商更改为杰克逊并丢失链接。

修改

由于我们没有找到任何集成上述技术的解决方案,我们决定从jettison迁移到jackson并实现(部分地,根据我们的需要量身定制)RESTEasy specification of atom link与我们自己的jackson兼容。我们建议这样的解决方案很容易,其他抛弃问题也会自动解决。

0 个答案:

没有答案