swagger-api / swagger-api/swagger-ui
Issues with output of XmlElementWrapper in swagger-ui 3.x
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 9.3k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 25
Description
Hi,
this is a re-post of https://github.com/swagger-api/swagger-core/issues/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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the supplied XmlElementWrapper example in swagger-ui 3.x and compare the expected XML wrapper and item names with the rendered error output. Done means wrapped arrays render using the schema's wrapper and item names instead of the nested error message.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100