Forum Discussion

pit's avatar
pit
Occasional Visitor
4 years ago

Java JAXB generated classes and swagger

I have JAXB generated classes
 
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "MyResponse", propOrder = {
    "member1",
    "member2",
    "member3"
})
public class MyResponse implements Serializable {
<... other class members; setters/ getters ...>
}

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "myRequest", propOrder = {
    "test1",
    "test2",
    "test3"
})
public class MyRequest implements Serializable {
    <... other class members; setters/ getters ...>
}

However, swagger 2 (version 3.0.0) generates example values as

<?xml version="1.0" encoding="UTF-8"?>
<JAXBElement«MyRequest»>
    <name>
        <localPart>jhgkhgk</localPart>
        <namespaceURI>gfjgfj</namespaceURI>
        <prefix>gfjhgfj</prefix>
    </name>
    <nil>true</nil>
    <MyRequest>
        <test1>string</test1>
        <test2>string</test2>
        <test3>string</test3>
    </MyRequest>
</JAXBElement«MyRequest»> 

How to force swagger to generate example values of

<MyRequest>
    <test1>string</test1>
    <test2>string</test2>
    <test3>string</test3>
</MyRequest>

My Controller class

public @ResponseBody JAXBElement<MyRequest> test(
        @RequestBody JAXBElement<MyResponse> message) {
}
No RepliesBe the first to reply