Skip to content

Issues with output of XmlElementWrapper in swagger-ui 3.x #2907

Open
@bill-okara

Description

@bill-okara

Hi,

this is a re-post of swagger-api/swagger-core#2170 against swagger-ui as per suggested.

To recap the issue,

using swagger 1.5.13, swagger-ui 3, the following jaxb annotations

@XmlElementWrapper(name = "messages)
@XmlElement(name = "message")
public List<Message> messages;

will be outputted (with swagger-jersey2-jaxrs) as:

"messages": {
    "type": "array",
    "xml": {
        "wrapped": true
    },
    "items": {
        "xml": {
            "name": "message"
        },
       "$ref": "#/definitions/Message"
   }
},
"Message":{
    "type":"object",
    "properties":
    ...
}

but in swagger-ui, it's being outputted as:

<messages>
    <messages type="error">
        <value>string</value>
    </messages>
</messages>

NOTE:
for fix testings, should note that if the XmlElementWrapper name and field name is the same (both equal to "messages" in this case, then will get

"messages": {
    "type": "array",
    "xml": {
        "wrapped": true
    },

but if they are not the same, like the following, then the spec output will be

@XmlElementWrapper(name = "messages)
@XmlElement(name = "message")
public List<Message> messageList;

"messageList": {
    "type": "array",
    "xml": {
       "name" : "messages"              <== note the 'name' here
        "wrapped": true
    },

Thanks,
Bill

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions