/json-schema-validator

Maven plugin to validate json files against a json schema. Uses https://github.com/fge/json-schema-validator library under the covers

Primary LanguageJavaApache License 2.0Apache-2.0

json-schema-validator

License: Apache 2 Travis Build Maven Artifact

Maven plugin to validate json files against a json schema. Uses https://github.com/fge/json-schema-validator library under the covers.

Usage

Determine the latest version of the validator in Maven Central.

Add the plugin to your pom either in the plugins or pluginManagement block:

<plugin>
    <groupId>com.groupon.maven.plugin.json</groupId>
    <artifactId>json-schema-validator</artifactId>
    <version>VERSION</version>
</plugin>

Configure one or more validation blocks for the plugin in the plugins block:

<plugin>
    <artifactId>json-schema-validator</artifactId>
    <groupId>com.groupon.maven.plugin.json</groupId>
    <executions>
        <execution>
            <phase>verify</phase>
            <goals>
                <goal>validate</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <validations>
            <validation>
                <directory>${basedir}/src/main/resources/data</directory>
                <jsonSchema>${basedir}/src/test/resources/data.schema</jsonSchema>
                <includes>
                    <include>**/*.json</include>
                </includes>
            </validation>
        </validations>
    </configuration>
</plugin>

Each validation block specifies the jsonSchema file to validate with as well as the json file(s) to validate from a root directory with standard includes and excludes to select specific file(s).

Building

Prerequisites:

Building:

json-schema-validator> mvn verify

To use the local version you must first install it locally:

json-schema-validator> mvn install

You can determine the version of the local build from the pom file. Using the local version is intended only for testing or development.

License

Published under Apache Software License 2.0, see LICENSE

© Groupon Inc., 2014