Skip to content

Advanced Plugin Configuration

Ivo Bek edited this page Jul 22, 2015 · 1 revision

Advanced Plugin Configuration

<plugin>
  <groupId>org.projectodd.jrapidoc</groupId>
  <artifactId>jrapidoc-rest-plugin</artifactId>
  <version>${jrapidoc.version}</version>
  <executions>
    <execution>
      <goals>
         <goal>run</goal>
      </goals>
    </execution>
  </executions>
  <configuration>
    <!--optional-->
    <modelTarget>${project.artifactId}-${project.version}/resources</modelTarget> <!-- target/jrapidoc-example-app-1.0/resources -->
    <custom>
      <appVersion>1.0</appVersion>
      <developerName>Sarzwest</developerName>
      <customPropertyPlacedToTheModel>Hello :-)</customPropertyPlacedToTheModel>
    </custom>
    <groups>
      <group>
        <baseUrl>http://localhost:8080/jrapidoc-example-app-1.0/jaxws/services</baseUrl>
        <!--optional-->
        <description>Not RPC web services</description>
        <includes>
          <include>org</include>
        </includes>
        <!--optional-->
        <excludes>
          <exclude>org.projectodd.jrapidoc.example.service.MessageRPCStyle</exclude>
        </excludes>
      </group>
      <group>
        <baseUrl>http://localhost:8080/jrapidoc-example-app-1.0/jaxws/services/rpc</baseUrl>
        <!--optional-->
        <description>Only RPC web services</description>
        <includes>
          <include>org</include>
        </includes>
        <!--optional-->
        <excludes>
          <exclude>org.projectodd.jrapidoc.example.service.Simple</exclude>
          <exclude>org.projectodd.jrapidoc.example.service.WithJRAPIDocAnnotations</exclude>
          <exclude>package.name.can.be.placed.here too</exclude>
        </excludes>
      </group>
    </groups>
    <!--optional-->
    <modelHandlers>
      <modelHandler>org.projectodd.jrapidoc.example.custom.AvoidSoapOneWayMethodsHandler</modelHandler>
    </modelHandlers>
    <!-- optional -->
    <typeProviderClass>org.projectodd.jrapidoc.model.type.provider.JacksonJsonProvider</typeProviderClass>
  </configuration>
</plugin>

Type Provider Classes

  • org.projectodd.jrapidoc.model.type.provider.JacksonJsonProvider (default for REST)
  • org.projectodd.jrapidoc.model.type.provider.JacksonJsonJaxbProvider
  • org.projectodd.jrapidoc.model.type.provider.JacksonJaxbProvider
  • org.projectodd.jrapidoc.model.type.provider.JacksonJaxbJsonProvider (default for SOAP)
  • OWN - inehrit from org.projectodd.jrapidoc.model.type.provider.TypeProvider

Custom API Model Processing

Simple example below checks if there are any REST methods without description, if yes, log a warning to the console. In model processing HandlerException can been thrown. See javadoc and example project for more information.

public class CheckRestMethodDescriptionHandler implements ModelHandler {
    @Override
    public void handleModel(APIModel model) throws HandlerException {
        for (ServiceGroup serviceGroup : model.getServiceGroups().values()) {
            for (Service service : serviceGroup.getServices().values()) {
                for (Method method : service.getMethods().values()) {
                    if (StringUtils.isEmpty(method.getDescription())) {
                        Logger.warn("Method {0} has not set description",
                                method.getPath());
                    }
                }
            }
        }
    }
}