15.2. Swagger Plugin

The first plugin implemented for Sonargraph's plugin infrastructure is the 'Swagger' plugin for Java. It exposes web resources and dependencies between them.

It finds exposed web service end points by looking at annotations like @RequestMapping or @Path. If a method is annotated with one of those annotation the web end point 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 you have to use the Swagger Java code generator to generate the client code and add the generated Java code as well as the compiled byte code to the Sonargraph project. The plugin can scan the generated Java code for web calls and will try to resolve the end point within the scope of the project. If it is not present 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.

Swagger Plugin Webservices
Figure 15.3. Swagger Plugin Webservices

The issues created because of calling webservices not allowed by your architecture are shown in Issues View.

Swagger Plugin Issues
Figure 15.4. Swagger Plugin Issues

The calls to REST endpoints found by 'Swagger' plugin are presented in Navigation View below 'External [Web]'.

Swagger Plugin External
Figure 15.5. Swagger Plugin External