Home

Awesome

Ant task to generate JSON Schemas using Jackson

Easily generate JSON Schemas from your Java classes with Apache Ant using the Jackson library and extension modules.

Usage

Preconditions

There are a few preconditions for using this Ant task:

  1. you need jackson-jsonschema-ant-task in your classpath (obvious)
  2. you need your Jackson annotated Java classes in your classpath
  3. you need the Jackson's jackson-module-jsonSchema and it's dependencies in your classpath

Example

<path id="project.classpath">
	<pathelement path="${java.class.path}/"/>
	<pathelement location="lib/" /> <!-- should contain jackson-module-jsonSchema and it's dependencies -->
	<pathelement path="classes/" /> <!-- path to your classes directory where you have the class for which you want to generate the JSON schema -->
	<pathelement path="/path/to/jackson-jsonschema-ant-task-VERSION.jar" />
</path>

<taskdef resource="com/github/xdarklight/jackson/jsonschema/jsonschematasks.properties" classpathref="project.classpath">
</taskdef>

<target name="generateJsonSchema">
  <jsonschema classname="fqdn.for.JsonJavaClass" destfile="doc/jsonSchema/test.jsonschema" />
</target>

Parameters

'jsonschema' task attributes

AttributeDescriptionRequired
classnameThe Java class for which the JSON Schema will be generated (including all referenced classes)yes
destfileThe target file to which the JSON Schema will be writtenyes

License

The Ant task is offered under the Apache 2.0 license, see LICENSE

Building a new release

mvn release:prepare