guardrail

Language

Java

Java generation ships through Maven and Gradle, plus the CLI. Modules include guardrail-java-support, guardrail-java-async-http, guardrail-java-dropwizard, and guardrail-java-spring-mvc.

Example Maven configuration

<plugin>
  <groupId>dev.guardrail</groupId>
  <artifactId>guardrail-maven-plugin_2.12</artifactId>
  <version><!-- latest --></version>
  <executions>
    <execution>
      <id>generate-app-server</id>
      <goals>
        <goal>generate-sources</goal>
      </goals>
      <configuration>
        <language>java</language>
        <framework>dropwizard</framework>
        <kind>server</kind>
        <specPath>server-spec.yaml</specPath>
        <packageName>example.generated</packageName>
      </configuration>
    </execution>
  </executions>
</plugin>

On JDK 9+ add javax.annotation:javax.annotation-api 1.3.2.

Vavr collections

The Java backend can emit standard collections (Optional, Map) or Vavr types (io.vavr.control.Option, io.vavr.collection.Vector). Specify modules instead of a single framework:

<modules>
  <module>java-vavr</module>
  <module>jackson</module>
  <module>dropwizard</module>
</modules>

Vavr is currently supported with Dropwizard.

Frameworks

  • Dropwizard
  • Spring MVC

See guardrail-sample-gradle-springmvc and the plugin notes.