17.3. Swagger Plugin

The 'Swagger' plugin for Java exposes web resources and dependencies between them. It finds exposed web service end points by looking at the javax.ws.rs.Path annotation. If a method is annotated with this annotation the web resource will be added as a child to the method in the Navigation view.

The much more difficult part is to find out who is calling those web end points. Right now the plugin detects calls generated by Swagger for the OkHttpClient framework. The generated client code and its class files need to be added to the Sonargraph workspace. The plugin scans the generated Java code for web calls, creates a 'Web Call' element as a child element of the originating method, and tries to resolve the web resource within the scope of the project. The web resources could have been created by another plugin. If no web resource is found the called end point will show up under the "External (Web)" node in the navigation view.

With the help of the plugin you can visualize the dependencies between your web/micro-services and also define an architectural model that would enforce restrictions on those dependencies. To achieve that just create a big Java project containing the code of all your web/micro-services. The Swagger plugin will then automatically add web/micro-service dependencies to the Sonargraph model.

Please contact us if you have a use case and need some support!

Related topics: