yaml-json-validator-maven-plugin Maven Plugin

A Maven Plugin to validate yaml and json document

License

License

Categories

Categories

Maven Build Tools JSON Data
GroupId

GroupId

com.github.sylvainlaurent.maven
ArtifactId

ArtifactId

yaml-json-validator-maven-plugin
Last Version

Last Version

1.0.4
Release Date

Release Date

Type

Type

maven-plugin
Description

Description

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

Project URL

https://github.com/sylvainlaurent/yaml-json-validator-maven-plugin
Source Code Management

Source Code Management

https://github.com/sylvainlaurent/yaml-json-validator-maven-plugin

Download yaml-json-validator-maven-plugin

How to add to project

<plugin>
    <groupId>com.github.sylvainlaurent.maven</groupId>
    <artifactId>yaml-json-validator-maven-plugin</artifactId>
    <version>1.0.4</version>
</plugin>

Dependencies

compile (5)

Group / Artifact Type Version
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.2.0
com.fasterxml.jackson.dataformat : jackson-dataformat-yaml jar 2.8.11
com.github.java-json-tools : json-schema-validator jar 2.2.10

provided (1)

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

test (2)

Group / Artifact Type Version
junit : junit jar 4.12
org.slf4j : slf4j-simple jar 1.6.3

Project Modules

There are no modules declared in this project.

yaml-json-validator-maven-plugin

Build Status

This maven plugin allows to validate yaml and json files to check that they are well formed and optionally validate against JSON schemas.

Both JSON and YAML files can be validated against a JSON schema. The library fge/json-schema-validator is internally used for this.

Plugin configuration

      <plugin>
        <groupId>com.github.sylvainlaurent.maven</groupId>
        <artifactId>yaml-json-validator-maven-plugin</artifactId>
        <version>...</version>
        <executions>
          <execution>
            <id>validate</id>
            <phase>validate</phase>
            <goals>
              <goal>validate</goal>
            </goals>
            <configuration>
              <validationSets>
                <validationSet>
                  <jsonSchema>src/main/resources/my-schema.json</jsonSchema>
                  <includes>
                    <include>src/main/resources/*.json</include>
                  </includes>
                  <excludes>
                    <exclude>src/main/resources/do-not-validate*.json</exclude>
                    <!-- <exclude> is optional, others may be added -->
                  </excludes>
                </validationSet>
                <validationSet>
                  <!-- no jsonSchema is specified, check only that file are well formed -->
                  <includes>
                    <include>src/main/resources/*.yml</include>
                  </includes>
                </validationSet>
              </validationSets>
              <!-- Duplicate keys detection is turned on by default. -->
              <detectDuplicateKeys>false</detectDuplicateKeys>
              <allowEmptyFiles>false</allowEmptyFiles>
              <!-- Allow comments in json files is turned off by default -->
              <allowJsonComments>true</allowJsonComments>
              <!-- Trailing commas are not allwed by default -->
              <allowTrailingComma>true</allowTrailingComma>
              <skip>false</skip>
            </configuration>
          </execution>
        </executions>
      </plugin>

Validation failures make the build fail.

Requires java 1.7.

Versions

Version
1.0.4
1.0.3
1.0.2
1.0.1
1.0.0