JAX-RS: Get swagger.json For Free!

JAX-RS analyzer maven plugin examines JAX-RS resources in your Java EE project and generates the swagger.json definition. There are no runtime dependencies, additional annotations or configuration required, you only have to include the plugin to your maven build and then mvn clean install your project:


<plugin>
	<groupId>com.sebastian-daschner</groupId>
	<artifactId>jaxrs-analyzer-maven-plugin</artifactId>
	<version>0.3</version>
	<executions>
		<execution>
			<goals>
				<goal>analyze-jaxrs</goal>
			</goals>
			<configuration>
				<!-- Available backends, defaults to plaintext -->
				<!-- <backend>plaintext</backend> -->
				<backend>swagger</backend>
			</configuration>
		</execution>
	</executions>
</plugin>


The recent release (swaggerina) of headlands ships with swagger-ui with the spec generated by the JAX-RS analyzer plugin. A drop-in WAR is also available.

Big thanks to Sebastian Daschner, an airhacks alumni, for this time-saver. I think you should star the repo: https://github.com/sdaschner/jaxrs-analyzer :-).

See you at Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting


NEW online workshop: WebStandards Igniter (online)

Airport MUC workshops: Java EE 7: Bootstrap, Effective, Architectures, Web, React and Angular, Testing and Microservices

Podcast: airhacks.fm and newsletter: airhacks.news

A book about rethinking Java EE Patterns

Comments:

Does SWAGGER works with subresource locator ? I tested an old version and this doesn't work ! Thank's

Posted by Yahiaoui on May 11, 2015 at 12:05 PM CEST #

But what is 'Swagger'?

Posted by javaservant on May 11, 2015 at 02:23 PM CEST #

Thanks for the great information and tip. This will make the process of documenting JAX-RS so much easier.

Posted by John Yeary on May 12, 2015 at 01:54 PM CEST #

Hi Adam, this is really great and very important for restful apis. I am also using a maven plugin which scans JaxRS annotations and generated json file describing the API in swagger spec format:

https://github.com/teamcarma/swagger-jaxrs-doclet

The interesting here is that you can enhance your API with javadoc tags (instead of using Swagger annotations).

I've also blogged about it here: https://rpestano.wordpress.com/2014/12/21/some-words-on-javaee-rest-and-swagger/

Posted by rmpestano on May 14, 2015 at 01:21 PM CEST #

Hello
Does JAX-RS Analyzer Maven plugin need a Java SE greater than 1.7?
Our CM is saying that JAX-RS Analyzer does not run with JAVA SE 1.7.

Regards
BN

Posted by BN on March 14, 2016 at 07:59 PM CET #

Post a Comment:
  • HTML Syntax: NOT allowed
realworldpatterns.com
Online Workshops
...the last 150 posts
...the last 10 comments
License