Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
bill-okara opened this issue Apr 12, 2017 · 2 comments
Open

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

bill-okara opened this issue Apr 12, 2017 · 2 comments

Comments

@bill-okara
Copy link

bill-okara commented Apr 12, 2017

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

@webron
Copy link
Contributor

webron commented Jun 5, 2018

There's still a small issue with what swagger-core outputs, but the rendered result is still wrong. It should take the name of the referenced model, whether that one has an xml property in it or not.

@diwenzheng
Copy link

Has the problem been fixed ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants