All Projects → BerkleyTechnologyServices → restdocs-spec

BerkleyTechnologyServices / restdocs-spec

Licence: Apache-2.0 license
A maven plugin for generating Open API and Postman Collection specifications using Spring Restdocs.

Programming Languages

java
68154 projects - #9 most used programming language
groovy
2714 projects
shell
77523 projects

Projects that are alternatives of or similar to restdocs-spec

mosec-maven-plugin
用于检测maven项目的第三方依赖组件是否存在安全漏洞。
Stars: ✭ 85 (+97.67%)
Mutual labels:  maven, maven-plugin
gatling-maven-plugin
Gatling Plugin for Maven
Stars: ✭ 30 (-30.23%)
Mutual labels:  maven, maven-plugin
specifications-ITS-REST
openEHR REST API Specifications
Stars: ✭ 20 (-53.49%)
Mutual labels:  api-documentation, openapi
mvn scalafmt
Scalafmt plugin for maven
Stars: ✭ 14 (-67.44%)
Mutual labels:  maven, maven-plugin
plexus-compiler
Plexus compiler a layer on top of compilers and used by maven-compiler-plugin
Stars: ✭ 24 (-44.19%)
Mutual labels:  maven, maven-plugin
macosappbundler-maven-plugin
Maven plugin for creating a native macOS bundle containing all dependencies required by a Maven project
Stars: ✭ 35 (-18.6%)
Mutual labels:  maven, maven-plugin
jcabi-mysql-maven-plugin
MySQL Maven Plugin: starts MySQL server on pre-integration phase and shuts it down on post-integration phase
Stars: ✭ 34 (-20.93%)
Mutual labels:  maven, maven-plugin
Versions Maven Plugin
Versions Maven Plugin
Stars: ✭ 199 (+362.79%)
Mutual labels:  maven, maven-plugin
openapi-viewer
Browse and test a REST API described with the OpenAPI 3.0 Specification
Stars: ✭ 85 (+97.67%)
Mutual labels:  api-documentation, openapi
dmn-check
A tool which performs static analyses on Decision Model Notation (DMN) files to detect bugs
Stars: ✭ 34 (-20.93%)
Mutual labels:  maven, maven-plugin
markdown-page-generator-plugin
Markdown to HTML Page Generator Maven Plugin
Stars: ✭ 48 (+11.63%)
Mutual labels:  maven, maven-plugin
ktlint-maven-plugin
Maven plugin for ktlint the Kotlin linter
Stars: ✭ 42 (-2.33%)
Mutual labels:  maven, maven-plugin
openapi-boilerplate
📘 Multi-file boilerplate for Open API Specification
Stars: ✭ 280 (+551.16%)
Mutual labels:  api-documentation, openapi
buildnumber-maven-plugin
BuildNumber Maven Plugin
Stars: ✭ 53 (+23.26%)
Mutual labels:  maven, maven-plugin
Docker Maven Plugin
INACTIVE: A maven plugin for Docker
Stars: ✭ 2,597 (+5939.53%)
Mutual labels:  maven, maven-plugin
snyk-maven-plugin
Test and monitor your projects for vulnerabilities with Maven. This plugin is officially maintained by Snyk.
Stars: ✭ 64 (+48.84%)
Mutual labels:  maven, maven-plugin
Sortpom
Maven plugin that helps the user sort pom.xml.
Stars: ✭ 185 (+330.23%)
Mutual labels:  maven, maven-plugin
Formatter Maven Plugin
Formatter Maven Plugin
Stars: ✭ 187 (+334.88%)
Mutual labels:  maven, maven-plugin
mvn-jlink
Maven plugin to provide way to work with jlink tool in maven projects
Stars: ✭ 34 (-20.93%)
Mutual labels:  maven, maven-plugin
dependency-update-maven-plugin
A Maven plugin that creates merge requests for dependency updates.
Stars: ✭ 23 (-46.51%)
Mutual labels:  maven, maven-plugin

Restdocs Spec Generation Support

Build Status Maven Central

Usage

First head over to the ePages-de/restdocs-api-spec project and follow the instructions for setting up the Spring REST Docs extension. That extension will produce resource.json files for each of your documented resources. You'll also notice that project provides a gradle plugin that can be used to read all the resource.json files and turn them into an OpenAPI spec file. That is exactly what this project does as well, only in the form of a maven plugin instead.

Here is a typical pom.xml configuration:

  <plugin>
    <groupId>io.github.berkleytechnologyservices</groupId>
    <artifactId>restdocs-spec-maven-plugin</artifactId>
    <version>${restdocs-spec.version}</version>
    <executions>
      <execution>
        <goals>
          <goal>generate</goal>
        </goals>
      </execution>
    </executions>
  </plugin>

That will read your resource.json snippet files found under the ${project.build.directory}/generated-snippets directory and produce an OpenAPI 2.0 YAML file at ${project.build.directory}/restdocs-spec/openapi-2.0.yml.

If you would prefer that the OpenAPI 2.0 document is in JSON format you can specify it like this:

  <plugin>
    <groupId>io.github.berkleytechnologyservices</groupId>
    <artifactId>restdocs-spec-maven-plugin</artifactId>
    <version>${restdocs-spec.version}</version>
    <executions>
      <execution>
        <goals>
          <goal>generate</goal>
        </goals>
        <configuration>
          <format>JSON</format>
        </configuration>
      </execution>
    </executions>
  </plugin>

You can also generate OpenAPI 3.0 or Postman Collection specification. For instance, this would generate OpenAPI 3.0:

  <plugin>
    <groupId>io.github.berkleytechnologyservices</groupId>
    <artifactId>restdocs-spec-maven-plugin</artifactId>
    <version>${restdocs-spec.version}</version>
    <executions>
      <execution>
        <goals>
          <goal>generate</goal>
        </goals>
        <configuration>
          <specification>OPENAPI_V3</specification><!-- switch this to POSTMAN_COLLECTION for Postman Collection specs -->
        </configuration>
      </execution>
    </executions>
  </plugin>

Finally, you can also generate multiple formats at once using the more verbose syntax:

  <plugin>
    <groupId>io.github.berkleytechnologyservices</groupId>
    <artifactId>restdocs-spec-maven-plugin</artifactId>
    <version>${restdocs-spec.version}</version>
    <executions>
      <execution>
        <goals>
          <goal>generate</goal>
        </goals>
        <configuration>
          <specifications>
            <specification>
              <type>OPENAPI_V2</type>
            </specification>
            <specification>
              <type>OPENAPI_V3</type>
              <format>JSON</format>
            </specification>
            <specification>
              <type>POSTMAN_COLLECTION</type>
              <filename>my-api-collection</filename>
            </specification>
          </specifications>
        </configuration>
      </execution>
    </executions>
  </plugin>

There are several other aspects you can optionally configure. Here is the full set of options with their default values:

  <plugin>
    <groupId>io.github.berkleytechnologyservices</groupId>
    <artifactId>restdocs-spec-maven-plugin</artifactId>
    <version>${restdocs-spec.version}</version>
    <executions>
      <execution>
        <goals>
          <goal>generate</goal>
        </goals>
        <configuration>
          <name>${project.artifactId}</name>
          <version>${project.version}</version>
          <host>localhost</host>
          <basePath></basePath>
          <schemes>
            <scheme>http</scheme>
          </schemes>
          <snippetsDirectory>${project.build.directory}/generated-snippets</snippetsDirectory>
          <specification>OPENAPI_V2</specification>
          <outputDirectory>${project.build.directory}/restdocs-spec</outputDirectory>
          <skip>false</skip>
          <format>YAML</format>
          <filename>openapi-2.0</filename>
          <separatePublicApi>false</separatePublicApi>
          <tags />
          <oauth2 />
        </configuration>
      </execution>
    </executions>
  </plugin>

Tags

By default the plugin will not generate any tags. You can optionally provide tags using the <tags /> element. Here is an example:

  <plugin>
    <groupId>io.github.berkleytechnologyservices</groupId>
    <artifactId>restdocs-spec-maven-plugin</artifactId>
    <version>${restdocs-spec.version}</version>
    <executions>
      <execution>
        <goals>
          <goal>generate</goal>
        </goals>
        <configuration>
          <tags>
            <tag>
              <name>pets</name>
              <description>Everything about your Pets</description>
            </tag>
            <tag>
              <name>store</name>
              <description>Access to Petstore orders</description>
            </tag>
          </tags>
        </configuration>
      </execution>
    </executions>
  </plugin>

OAuth2 Configuration

By default the plugin will not generate any security information. You can optionally provide it using the <oauth2 /> element. Here is an example:

  <plugin>
    <groupId>io.github.berkleytechnologyservices</groupId>
    <artifactId>restdocs-spec-maven-plugin</artifactId>
    <version>${restdocs-spec.version}</version>
    <executions>
      <execution>
        <goals>
          <goal>generate</goal>
        </goals>
        <configuration>
          <oauth2>
            <tokenUrl>http://example.com/uaa/token</tokenUrl>
            <authorizationUrl>http://example.com/uaa/authorize</authorizationUrl>
            <flows>
              <flow>accessCode</flow>
              <flow>implicit</flow>
            </flows>
            <scopes>
              <scope>
                <name>read</name>
                <description>Access to read operations.</description>
              </scope>
              <scope>
                <name>write</name>
                <description>Access to write operations.</description>
              </scope>
            </scopes>
          </oauth2>
        </configuration>
      </execution>
    </executions>
  </plugin>

Example

You can find a full example project here: https://github.com/BerkleyTechnologyServices/restdocs-spec-example

Still in development

  • Support for additional specification formats is currently in development. We plan to add support for Postman Collections and RAML.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].