Skip to content
This repository has been archived by the owner on May 26, 2020. It is now read-only.

Commit

Permalink
update the README for the project
Browse files Browse the repository at this point in the history
  • Loading branch information
amckenzie committed Dec 4, 2017
1 parent d0ea9e6 commit 461a87e
Showing 1 changed file with 59 additions and 1 deletion.
60 changes: 59 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
This library is intended as a json version of XML Catalogs: https://www.oasis-open.org/committees/entity/spec-2001-08-06.html

## Overview

### Catalog
Json Schema Catalog is a Maven Plugin which allows easy inclusion of references in json schema documents to other json schemas, without the need to host the fragment schemas on a server, and/or to solve the problems of paths if the fragment schemas are stored on a file system. This allows for common standard schema definitions like *address* or *UUID* to be commonly used in all json schema documents and for these fragment schemas to be shared as jars.


Expand Down Expand Up @@ -49,7 +51,7 @@ Which defines a schema fragment *address.json* using the url http://justice.gov.
}
}

Normally, when person-schema.json is used to validate against a json document, whichever library you are using to handle json schema (we are using the excellent Everit json validator: https://github.com/everit-org/json-schema), would load the fragment schema from the URI defined in the reference. i.e. http://justice.gov.uk/standard/fragments/address.json.
Normally, when person-schema.json is used to validate against a json document, whichever library you are using to handle json schema (we are using the excellent [Everit Json Schema Validator](https://github.com/everit-org/json-schema)), would load the fragment schema from the URI defined in the reference. i.e. http://justice.gov.uk/standard/fragments/address.json.

Instead, we build a catalog of all json schemas found on the classpath (at a known location) which maps the id of the schema against it's base location (e.g. jar etc.) and its path in that location:

Expand Down Expand Up @@ -91,3 +93,59 @@ When a json document is validated, we override the call to the fragment id url a

For this to work, each schema file *must* define an id and that id *must* match the reference given in the main json schema document.

For this to work, each schema file *must* define an id and that id *must* match the reference given in the main json schema document.

## Usage

To add to your project add the following to your plugin declaration (edited to taste):


<plugin>
<artifactId>generator-plugin</artifactId>
<groupId>uk.gov.justice.maven.generator</groupId>
<version>${generator-maven-plugin.version}</version>
<executions>
<execution>
<id>internal-jsons</id>
<configuration>
<generatorName>
uk.gov.justice.schema.catalog.generation.maven.MavenCatalogGeneratorFactory
</generatorName>
<parserName>
uk.gov.justice.schema.catalog.generation.io.parser.ListOfUriParser
</parserName>
<basePackageName>uk.gov.justice.events.pojo</basePackageName>
<sourceDirectory>${basedir}/src/main/resources/json/schema
</sourceDirectory>
<outputDirectory>${project.build.directory}/generated-resources</outputDirectory>
<includes>
<include>**/*.json</include>
</includes>
<excludes>
</excludes>
<generatorProperties implementation="uk.gov.justice.schema.catalog.generation.maven.CatalogGeneratorProperties">
<catalogName>${project.artifactId}</catalogName>
</generatorProperties>
</configuration>
<goals>
<goal>generate</goal>
</goals>
<phase>generate-sources</phase>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>uk.gov.justice.schema</groupId>
<artifactId>catalog-generation</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</plugin>

The relevant parts of this plugin definition are:

* sourceDirectory: the location of your json schemas
* basePackageName: um...



0 comments on commit 461a87e

Please sign in to comment.