Java – Jersey 2 generates WADL schema using method parameters

I am using Jersey 2 and want to generate WADL architecture

<resource path="/addItem">
    <method id="addItem" name="POST">
        <request>
            <representation mediaType="application/json"/>
        </request>
        <response>
            <representation mediaType="application/json"/>
        </response>
    </method>
</resource>

And my service looks like:

@POST
@Path("/addItem")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response addItem(ItemDto item) {
    cartService.addItem(item);
    return Response.ok().build();
}

Can I get more information about itemdto in my WADL plan?

Solution

WADL itself, AFAIK does not provide more information than you get Well, actually, that's true, because since Jersey 2.5 Since 1, some non user-defined resources and methods have been hidden in the default / application WADL response in progress To see more (but still not what you want to implement), you can call the WADL resource with the detailed query parameter, / application wadl? Detail = true, please refer to Chapter 16 in Jersey documentation

Back to your question – if I understand correctly, what you want Jersey to do is automatically expose your bean JSON schemas in WADL, right?

Currently in jersey-2 This is not easy to implement in X Gerard Davison is in jersey-1 X has an extension module, but the support has not been ported to jersey-2 X (currently only XSD is supported)

However, Jersey has an issue in the backlog, so be patient and you may get an out of the box solution one day

In the meantime, you can try to execute the quick and a bit dirty solution described in Gerald's blog post

I know the answer is a little late, but I still hope it helps

Good luck

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>