Java JSON Schema Generator

Java JSON Schema Generator – creating a JSON Schema (Draft 7) from your Java classes

License

License

Categories

Categories

JSON Data
GroupId

GroupId

com.github.janlabrie
ArtifactId

ArtifactId

jsonschema-generator
Last Version

Last Version

4.3.1
Release Date

Release Date

Type

Type

jar
Description

Description

Java JSON Schema Generator
Java JSON Schema Generator – creating a JSON Schema (Draft 7) from your Java classes
Project URL

Project URL

https://github.com/janlabrie/jsonschema-generator
Project Organization

Project Organization

JanLabrie
Source Code Management

Source Code Management

https://github.com/janlabrie/jsonschema-generator

Download jsonschema-generator

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.janlabrie/jsonschema-generator/ -->
<dependency>
    <groupId>com.github.janlabrie</groupId>
    <artifactId>jsonschema-generator</artifactId>
    <version>4.3.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.janlabrie/jsonschema-generator/
implementation 'com.github.janlabrie:jsonschema-generator:4.3.1'
// https://jarcasting.com/artifacts/com.github.janlabrie/jsonschema-generator/
implementation ("com.github.janlabrie:jsonschema-generator:4.3.1")
'com.github.janlabrie:jsonschema-generator:jar:4.3.1'
<dependency org="com.github.janlabrie" name="jsonschema-generator" rev="4.3.1">
  <artifact name="jsonschema-generator" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.janlabrie', module='jsonschema-generator', version='4.3.1')
)
libraryDependencies += "com.github.janlabrie" % "jsonschema-generator" % "4.3.1"
[com.github.janlabrie/jsonschema-generator "4.3.1"]

Dependencies

compile (7)

Group / Artifact Type Version
com.fasterxml : classmate jar 1.5.0
com.fasterxml.jackson.core : jackson-core jar 2.10.0
com.fasterxml.jackson.core : jackson-databind jar 2.10.0
org.apache.logging.log4j : log4j-api Optional jar 2.11.2
org.apache.logging.log4j : log4j-core Optional jar 2.11.2
org.apache.logging.log4j : log4j-slf4j-impl Optional jar 2.11.2
org.slf4j : slf4j-api jar 1.7.26

test (4)

Group / Artifact Type Version
junit : junit jar 4.12
pl.pragmatists : JUnitParams jar 1.1.1
org.mockito : mockito-core jar 2.27.0
org.skyscreamer : jsonassert jar 1.5.0

Project Modules

There are no modules declared in this project.

Java JSON Schema Generator

Build Status Maven Central

Creating JSON Schema (Draft 6, Draft 7 or Draft 2019-09) from your Java classes utilising Jackson.


This project consists of:

Another example for such a module is:


Documentation

JavaDoc is being used throughout the codebase, offering contextual information in your respective IDE or being available online through services like javadoc.io.

Additional documentation can be found in the Project Wiki.


Usage

Dependency (Maven)

<dependency>
    <groupId>com.github.victools</groupId>
    <artifactId>jsonschema-generator</artifactId>
    <version>4.13.0</version>
</dependency>

Since version 4.7, the release versions of the main generator library and the (standard) victools modules listed above are aligned. It is recommended to use identical versions for all of them to ensure compatibility.

Code

Complete/Minimal Example

import com.fasterxml.jackson.databind.JsonNode;
import com.github.victools.jsonschema.generator.OptionPreset;
import com.github.victools.jsonschema.generator.SchemaGenerator;
import com.github.victools.jsonschema.generator.SchemaGeneratorConfig;
import com.github.victools.jsonschema.generator.SchemaGeneratorConfigBuilder;
import com.github.victools.jsonschema.generator.SchemaVersion;
SchemaGeneratorConfigBuilder configBuilder = new SchemaGeneratorConfigBuilder(SchemaVersion.DRAFT_2019_09, OptionPreset.PLAIN_JSON);
SchemaGeneratorConfig config = configBuilder.build();
SchemaGenerator generator = new SchemaGenerator(config);
JsonNode jsonSchema = generator.generateSchema(YourClass.class);

System.out.println(jsonSchema.toString());

Versions

Version
4.3.1