swagger-validator-maven-plugin Maven Plugin

A Maven Plugin to validate yaml and json swagger document

License

License

Categories

Categories

Maven Build Tools Swagger Program Interface REST Frameworks
GroupId

GroupId

com.github.giuliopulina
ArtifactId

ArtifactId

swagger-validator-maven-plugin
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

maven-plugin
Description

Description

swagger-validator-maven-plugin Maven Plugin
A Maven Plugin to validate yaml and json swagger document
Project URL

Project URL

https://github.com/giuliopulina/swagger-validator-maven-plugin
Source Code Management

Source Code Management

https://github.com/giuliopulina/swagger-validator-maven-plugin.git

Download swagger-validator-maven-plugin

How to add to project

<plugin>
    <groupId>com.github.giuliopulina</groupId>
    <artifactId>swagger-validator-maven-plugin</artifactId>
    <version>1.0.0</version>
</plugin>

Dependencies

compile (10)

Group / Artifact Type Version
org.reflections : reflections jar 0.9.11
org.apache.maven : maven-plugin-api jar 3.0
org.apache.maven : maven-project jar 2.2.1
org.codehaus.plexus : plexus-utils jar 3.0.8
com.fasterxml.jackson.dataformat : jackson-dataformat-yaml jar 2.9.8
com.github.fge : json-schema-validator jar 2.2.6
io.swagger : swagger-parser jar 1.0.44
org.apache.commons : commons-lang3 jar 3.6
org.apache.commons : commons-collections4 jar 4.1
net.bytebuddy : byte-buddy jar 1.9.13

provided (1)

Group / Artifact Type Version
org.apache.maven.plugin-tools : maven-plugin-annotations jar 3.4

test (3)

Group / Artifact Type Version
junit : junit jar 4.8.2
org.slf4j : slf4j-simple jar 1.7.22
org.slf4j : slf4j-api jar 1.7.22

Project Modules

There are no modules declared in this project.

Build Status

swagger-validator-maven-plugin

This maven plugin allows to validate yaml and json files.

Plugin configuration

      <plugin>
        <groupId>com.github.giuliopulina</groupId>
        <artifactId>swagger-validator-maven-plugin</artifactId>
        <version>...</version>
        <executions>
          <execution>
            <id>validate</id>
            <phase>validate</phase>
            <goals>
              <goal>validate</goal>
            </goals>
            <configuration>
                <failOnErrors>true</failOnErrors>
              <includes>
                <include>src/main/resources/swagger-*.yml</include>
                <include>src/main/resources/swagger-*.json</include>
                <!-- other <include> may be added -->
              </includes>
              <excludes>
                <exclude>src/main/resources/swagger-do-not-validate*.yml</exclude>
                <!-- <exclude> is optional, others may be added -->
              </excludes>
              <!-- package names where custom validators are located -->
              <customModelValidatorsPackage>com.example.validators</customModelValidatorsPackage>
              <customPathValidatorsPackage>com.example.validators</customPathValidatorsPackage>
            </configuration>
          </execution>
        </executions>
        <dependencies>
            <!-- dependency with custom validators -->
            <dependency>
                <groupId>com.example</groupId>
                <artifactId>custom-validators</artifactId>
                <version>${project.version}</version>
            </dependency>
        </dependencies>
      </plugin>

Validation failures make the build fail but default. You can change this by setting <failOnErrors>false</failOnErrors>.

You can add your custom validators and provide plugin with them. Extend from ModelValidatorTemplate or PathValidatorTemplate classes for writing your validators and override necessary validation methods. See ReferenceValidator and PathValidator as examples.

Requires java 1.8.

Source code

The source code is available on GitHub : https://github.com/giuliopulina/swagger-validator-maven-plugin

How to build source

Use Maven and a JDK >=8, and run mvn clean verify in the root directory of the git repository.

How to create a release

mvn release:prepare release:perform and answer the questions about version number.

Then push the commits and tags to github.

License

This software is licensed under the Apache Sotware License version 2.0, see LICENSE.txt.

Versions

Version
1.0.0