Is there a tool which takes a Java File what describes a REST service as a parameter and generates a wadl file out of that.
问题:
回答1:
I had the same problem: was using RESTeasy and wanted to find a way to generate the WADL automatically.
Did some research and came to the solution below.
1. Add this to your pom.xml
:
com.sun.jersey.contribs maven-wadl-plugin 1.17 generate generate ${javadoc-phase} ${project.build.outputDirectory}/application.wadl true http://example.com:8080/rest com.example.rs.resource com.sun.jersey.server.wadl.generators.WadlGeneratorApplicationDoc applicationDocsFile ${basedir}/src/main/doc/application-doc.xml com.sun.jersey.server.wadl.generators.WadlGeneratorGrammarsSupport grammarsFile ${basedir}/src/main/doc/application-grammars.xml
Pay attention to the buildUri
and packagesResourceConfig
elements. You have to change them to reflect your project's configuration. You may also want to change the plugin's version (I used 1.17).
2. Create a /doc folder and add some files.
Create the src/main/doc/
folder and create the two files below.
File: application-doc.xml
Content:
This is added to the start of the generated application.wadl
File: application-grammars.xml
Content:
3. Run the maven command.
Go to the project folder and run the following command:
$ mvn compile com.sun.jersey.contribs:maven-wadl-plugin:generate
The files \target\classes\application.wadl
(the WADL itself) and \target\classes\xsd0.xsd
(the schema of the resources - it's used by the application.wadl) should be generated.
Edit and use them as you wish.
PS.: Bear in mind that this is a very simple use of the maven-wadl-plugin. It can do a lot more. To know it better, please refer to the zip file mentioned in the other answer (by Pavel Bucek).
回答2:
Yes, please see gerenate-wadl [1] sample from Jersey samples (look for maven-wadl-plugin).