@ApiOperation(value="Return List<Item>",
notes="Let Jersey/JAXB do the element wrapping")
@GET
@Path("list")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public List<Item> getModels() {
return Arrays.asList(new Item("1", "foo"), new Item("2", "bar"));
}
@ApiOperation(value="Return Items, which contains List<Item>",
notes="JAXB annotations are used so that the result is semantical equivalent to List<Iterm> been returned")
@GET
@Path("items")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Items getItems() {
return new Items(Arrays.asList(new Item("1", "foo"), new Item("2", "bar")));
}
@XmlRootElement(namespace="io.swagger.bug-test")
@XmlAccessorType(XmlAccessType.NONE)
public final class Item extends Object {
@XmlAttribute(required=true)
@XmlSchemaType(name="ID")
private String id;
@XmlElement(required=true)
private String value;
...
}
@XmlRootElement(name="items")
@XmlAccessorType(XmlAccessType.NONE)
public final class Items extends Object {
@XmlElement(namespace="io.swagger.bug-test")
private List<Item> item;
...
}
swagger: "2.0"
paths:
/list:
get:
summary: "Return List<Item>"
description: "Let Jersey/JAXB do the element wrapping"
operationId: "getModels"
produces:
- "application/json"
- "application/xml"
parameters: []
responses:
200:
description: "successful operation"
schema:
type: "array"
items:
$ref: "#/definitions/Item"
/items:
get:
summary: "Return Items, which contains List<Item>"
description: "JAXB annotations are used so that the result is semantical equivalent\
\ to List<Iterm> been returned"
operationId: "getItems"
produces:
- "application/json"
- "application/xml"
parameters: []
responses:
200:
description: "successful operation"
schema:
$ref: "#/definitions/Items"
definitions:
Item:
type: "object"
required:
- "value"
properties:
value:
type: "string"
Items:
type: "object"
properties:
item:
type: "array"
xml:
namespace: "io.swagger.bug-test"
items:
$ref: "#/definitions/Item"
xml:
name: "items"
GET /list
<?xml version="1.0"?>
<Inline Model>
<value>string</value>
</Inline Model>
GET /items
<?xml version="1.0"?>
<items xmlns="io.swagger.bug-test">
<item>
<value>string</value>
</item>
</items>
GET /list
<?xml version="1.0" encoding="UTF-8"?>
<items>
<ns:item xmlns:ns="io.swagger.bug-test" id="string">
<value>string</value>
</ns:item>
</items>
GET /items
<?xml version="1.0" encoding="UTF-8"?>
<items>
<ns:item xmlns:ns="io.swagger.bug-test" id="string">
<value>string</value>
</ns:item>
</items>
swagger: "2.0"
paths:
/list:
get:
summary: "Return List<Item>"
description: "Let Jersey/JAXB do the element wrapping"
operationId: "getModels"
produces:
- "application/json"
- "application/xml"
parameters: []
responses:
200:
description: "successful operation"
schema:
type: "array"
xml:
wrapped: "true"
name: "items"
items:
$ref: "#/definitions/Item"
/items:
get:
summary: "Return Items, which contains List<Item>"
description: "JAXB annotations are used so that the result is semantical equivalent\
\ to List<Iterm> been returned"
operationId: "getItems"
produces:
- "application/json"
- "application/xml"
parameters: []
responses:
200:
description: "successful operation"
schema:
$ref: "#/definitions/Items"
definitions:
Item:
type: "object"
required:
- "value"
properties:
id:
type: "string"
xml:
attribute: "true"
value:
type: "string"
xml:
name: "item"
namespace: "io.swagger.bug-test"
Items:
type: "object"
properties:
item:
type: "array"
items:
$ref: "#/definitions/Item"
xml:
name: "items"
<?xml version="1.0" encoding="UTF-8"?>
<items>
<item xmlns="io.swagger.bug-test" id="string">
<value>string</value>
</item>
</items>
GET /list
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<items>
<ns2:item xmlns:ns2="io.swagger.bug-test" id="1">
<value>foo</value>
</ns2:item>
<ns2:item xmlns:ns2="io.swagger.bug-test" id="2">
<value>bar</value>
</ns2:item>
</items>
GET /items
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<items xmlns:ns2="io.swagger.bug-test">
<ns2:item id="1">
<value>foo</value>
</ns2:item>
<ns2:item id="2">
<value>bar</value>
</ns2:item>
</items>
Thanks for the elaborate investigation.
Since there’s a ticket opened for the second issue you mentioned, would you mind opening one for the first issue?
--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.