REST automation, generating Java types

I think I done a general mistake with REST automation.

When I read the documentation it pointed to a WADL file and said it is meant as a reference. So I assumed there is no way to use it to automatically generate Java classes for the types.

The REST auotmation code I wrote is totally handwritten.

But now it seems to me there is a way to generate an API from the WADL and associated XSD files. Is that right?

Why don't you document this? Or where can I find a documentation on how to use that Jersey WADL in order to do state of the art REST automation from Java? What best practices do you recommend here?

I don't like my handwritten code since I stuggle with my own bugs there, which could be avoided if I knew only how to generate that part.

5 comments
Comment actions Permalink

Hi Ernesto,

While there are several generators of client code based on WADL out there, we've not yet found one we can recommend.

What generator do you have in mind?

0
Comment actions Permalink

Previously I generated Java files from XSD files with JAXB. It was for using REST API from HP Quality Center. Actually that worked, don't know if JAXB is the best thing for that, but it solved that part of the problem.

But with WADL there is even more possibilities perhaps since you could generate code from the whole WADL and not just for the XSD part.

Somehow the WADL was generated, so it might be possible the other way, to generate Java from a WADL. But that I haven't done yet so it would be great if someone could point me to something.

0
Comment actions Permalink

Ernesto,

Thank you for the details. As I've said at this moment we have no tool to recommend

We've tried several linked in the issue, and with some tweals they can generate some client code, however the result if far from API which is not a pain to use.
At this time we are experimenting with the generator from Swagger project, but so far there are no results to share.

0
Comment actions Permalink

Thank you for the information.
Do I understand you right, that writing that API myself (including Java types for TeamCity build types, parameters etc.) is currently a good approach because the tools for code generation are not good enough currently?

0
Comment actions Permalink

Ernesto,

It's a question you need to answer for yourself as we indeed do not have a recommended approach here.
You can check the alavilable generic generators and decide if it would be OK to use any of those or maintain your own code.

Typical scenario we've seen is to use one of generators and then refactor the code to a usable state.

0

Please sign in to leave a comment.