Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
java_version: ['8', '11', '17']
java_version: ['17']
env:
JAVA_OPTS: "-XX:+TieredCompilation -XX:TieredStopAtLevel=1"
steps:
Expand Down
28 changes: 11 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,28 @@ And if necessary, more if future revisions also prove incompatible.
## Status

[![Build Status](https://travis-ci.org/FasterXML/jackson-module-jsonSchema.svg)](https://travis-ci.org/FasterXML/jackson-module-jsonSchema)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.fasterxml.jackson.module/jackson-module-jsonSchema/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.fasterxml.jackson.module/jackson-module-jsonSchema/)
[![Javadoc](https://javadoc.io/badge/com.fasterxml.jackson.module/jackson-module-jsonSchema.svg)](http://www.javadoc.io/doc/com.fasterxml.jackson.module/jackson-module-jsonSchema)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/tools.jackson.module/jackson-module-jsonSchema/badge.svg)](https://maven-badges.herokuapp.com/maven-central/tools.jackson.module/jackson-module-jsonSchema/)
[![Javadoc](https://javadoc.io/badge/tools.jackson.module/jackson-module-jsonSchema.svg)](http://www.javadoc.io/doc/tools.jackson.module/jackson-module-jsonSchema)

Version 2.4 was considered the first stable version of the module.

## Two modules (with Jackson 2.15)
## Two modules

Starting with upcoming Jackson 2.15, this repository contains TWO versions of the module:
This repository contains TWO versions of the module:

1. Old JSON Schema module `com.fasterxml.jackson.module:jackson-module-jsonSchema` (since 2.0)
2. New JSON Schema module `com.fasterxml.jackson.module:jackson-module-jsonSchema-jakarta` (2.15+)
1. javax: `tools.jackson.module:jackson-module-jsonSchema`
2. jakarta: `tools.jackson.module:jackson-module-jsonSchema-jakarta`

depending on whether system needs to work with "old" `javax`/`JAXB` APIs (first module) or newer "Jakarta" APIs.

## Future plans (lack thereof)

Due to lack of support by community, this module is NOT planned to be supported beyond
Jackson 2.x -- no work has been done for it to work with future Jackson 3.0.
Users are encouraged to use more up-to-date JSON Schema support tools.

## Example Usage

(from [TestGenerateJsonSchema](https://github.com/FasterXML/jackson-module-jsonSchema/blob/master/javax/src/test/java/com/fasterxml/jackson/module/jsonSchema/TestGenerateJsonSchema.java#L136))
(from [TestGenerateJsonSchema](https://github.com/FasterXML/jackson-module-jsonSchema/blob/master/javax/src/test/java/tools/jackson/module/jsonSchema/TestGenerateJsonSchema.java#L136))

simply add a dependency
`"com.fasterxml.jackson.module:jackson-module-jsonSchema:2.15.0"`
`"tools.jackson.module:jackson-module-jsonSchema:3.1.0"`
or
`"com.fasterxml.jackson.module:jackson-module-jsonSchema-jakarta:2.15.0"` for the jakarta namespace
`"tools.jackson.module:jackson-module-jsonSchema-jakarta:3.1.0"` for the jakarta namespace

and for gradle, at least, you can simply add `mavenLocal()` to your repositories.
Maven should resolve the dependency from its local repo transparently.
Expand All @@ -54,7 +48,7 @@ This will yield a java pojo representing a JSON Schema, which can itself easily

## Adding Property Processing

See `com.fasterxml.jackson.module.jsonSchema.customProperties.TitleSchemaFactoryWrapper` for an example of writing custom schema properties.
See `tools.jackson.module.jsonSchema.customProperties.TitleSchemaFactoryWrapper` for an example of writing custom schema properties.

## Required Fields

Expand All @@ -68,7 +62,7 @@ Currently 2 aspects of IETF supported:
* pathStart - URI that defines what the instance's URI MUST start with in order to validate.
* links - associated Link Description Objects with instances.

You can enable HypermediaSupport using `com.fasterxml.jackson.module.jsonSchema.customProperties.HyperSchemaFactoryWrapper`.
You can enable HypermediaSupport using `tools.jackson.module.jsonSchema.customProperties.HyperSchemaFactoryWrapper`.
Example:

```java
Expand Down
6 changes: 3 additions & 3 deletions jakarta/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<!-- do_not_remove: published-with-gradle-metadata -->
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.fasterxml.jackson.module</groupId>
<groupId>tools.jackson.module</groupId>
<artifactId>jackson-module-jsonSchema-parent</artifactId>
<version>2.21.0-SNAPSHOT</version>
<version>3.1.0-SNAPSHOT</version>
</parent>
<artifactId>jackson-module-jsonSchema-jakarta</artifactId>
<name>jackson-module-jsonSchema-jakarta</name>
Expand All @@ -34,7 +34,7 @@ JSON Schema (http://tools.ietf.org/html/draft-zyp-json-schema-03) version 3 gene
<version>${version.plugin.surefire}</version>
<configuration>
<excludes>
<exclude>com/fasterxml/jackson/module/jsonSchema/jakarta/failing/*.java</exclude>
<exclude>tools/jackson/module/jsonSchema/jakarta/failing/*.java</exclude>
</excludes>
</configuration>
</plugin>
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
package com.fasterxml.jackson.module.jsonSchema.jakarta;
package tools.jackson.module.jsonSchema.jakarta;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeInfo.As;
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
import com.fasterxml.jackson.databind.BeanProperty;
import com.fasterxml.jackson.databind.annotation.JsonTypeIdResolver;
import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatTypes;
import com.fasterxml.jackson.module.jsonSchema.jakarta.types.AnySchema;
import com.fasterxml.jackson.module.jsonSchema.jakarta.types.ArraySchema;
import com.fasterxml.jackson.module.jsonSchema.jakarta.types.BooleanSchema;
import com.fasterxml.jackson.module.jsonSchema.jakarta.types.ContainerTypeSchema;
import com.fasterxml.jackson.module.jsonSchema.jakarta.types.IntegerSchema;
import com.fasterxml.jackson.module.jsonSchema.jakarta.types.NullSchema;
import com.fasterxml.jackson.module.jsonSchema.jakarta.types.NumberSchema;
import com.fasterxml.jackson.module.jsonSchema.jakarta.types.ObjectSchema;
import com.fasterxml.jackson.module.jsonSchema.jakarta.types.SimpleTypeSchema;
import com.fasterxml.jackson.module.jsonSchema.jakarta.types.StringSchema;
import com.fasterxml.jackson.module.jsonSchema.jakarta.types.UnionTypeSchema;
import com.fasterxml.jackson.module.jsonSchema.jakarta.types.ValueTypeSchema;
import tools.jackson.databind.BeanProperty;
import tools.jackson.databind.annotation.JsonTypeIdResolver;
import tools.jackson.databind.jsonFormatVisitors.JsonFormatTypes;
import tools.jackson.module.jsonSchema.jakarta.types.AnySchema;
import tools.jackson.module.jsonSchema.jakarta.types.ArraySchema;
import tools.jackson.module.jsonSchema.jakarta.types.BooleanSchema;
import tools.jackson.module.jsonSchema.jakarta.types.ContainerTypeSchema;
import tools.jackson.module.jsonSchema.jakarta.types.IntegerSchema;
import tools.jackson.module.jsonSchema.jakarta.types.NullSchema;
import tools.jackson.module.jsonSchema.jakarta.types.NumberSchema;
import tools.jackson.module.jsonSchema.jakarta.types.ObjectSchema;
import tools.jackson.module.jsonSchema.jakarta.types.SimpleTypeSchema;
import tools.jackson.module.jsonSchema.jakarta.types.StringSchema;
import tools.jackson.module.jsonSchema.jakarta.types.UnionTypeSchema;
import tools.jackson.module.jsonSchema.jakarta.types.ValueTypeSchema;

/**
* The type wraps the json schema specification at :
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.fasterxml.jackson.module.jsonSchema;
package tools.jackson.module.jsonSchema.jakarta;

import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.module.jsonSchema.factories.SchemaFactoryWrapper;
import com.fasterxml.jackson.module.jsonSchema.factories.WrapperFactory;
import tools.jackson.databind.*;
import tools.jackson.module.jsonSchema.jakarta.factories.SchemaFactoryWrapper;
import tools.jackson.module.jsonSchema.jakarta.factories.WrapperFactory;

/**
* Convenience class that wraps JSON Schema generation functionality.
Expand Down Expand Up @@ -80,7 +80,7 @@ public JsonSchemaGenerator(ObjectWriter w, SchemaFactoryWrapper visitor) {
_visitor = visitor;
}

public JsonSchema generateSchema(Class<?> type) throws JsonMappingException
public JsonSchema generateSchema(Class<?> type)
{
SchemaFactoryWrapper visitor = _visitor;
if (visitor == null) {
Expand All @@ -90,7 +90,7 @@ public JsonSchema generateSchema(Class<?> type) throws JsonMappingException
return visitor.finalSchema();
}

public JsonSchema generateSchema(JavaType type) throws JsonMappingException
public JsonSchema generateSchema(JavaType type)
{
SchemaFactoryWrapper visitor = _visitor;
if (visitor == null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
package com.fasterxml.jackson.module.jsonSchema.jakarta;
package tools.jackson.module.jsonSchema.jakarta;

import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
import com.fasterxml.jackson.databind.DatabindContext;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatTypes;
import com.fasterxml.jackson.databind.jsontype.impl.TypeIdResolverBase;
import com.fasterxml.jackson.module.jsonSchema.jakarta.types.AnySchema;
import com.fasterxml.jackson.module.jsonSchema.jakarta.types.ArraySchema;
import com.fasterxml.jackson.module.jsonSchema.jakarta.types.BooleanSchema;
import com.fasterxml.jackson.module.jsonSchema.jakarta.types.IntegerSchema;
import com.fasterxml.jackson.module.jsonSchema.jakarta.types.NullSchema;
import com.fasterxml.jackson.module.jsonSchema.jakarta.types.NumberSchema;
import com.fasterxml.jackson.module.jsonSchema.jakarta.types.ObjectSchema;
import com.fasterxml.jackson.module.jsonSchema.jakarta.types.StringSchema;
import tools.jackson.databind.DatabindContext;
import tools.jackson.databind.JavaType;
import tools.jackson.databind.jsonFormatVisitors.JsonFormatTypes;
import tools.jackson.databind.jsontype.impl.TypeIdResolverBase;
import tools.jackson.module.jsonSchema.jakarta.types.AnySchema;
import tools.jackson.module.jsonSchema.jakarta.types.ArraySchema;
import tools.jackson.module.jsonSchema.jakarta.types.BooleanSchema;
import tools.jackson.module.jsonSchema.jakarta.types.IntegerSchema;
import tools.jackson.module.jsonSchema.jakarta.types.NullSchema;
import tools.jackson.module.jsonSchema.jakarta.types.NumberSchema;
import tools.jackson.module.jsonSchema.jakarta.types.ObjectSchema;
import tools.jackson.module.jsonSchema.jakarta.types.StringSchema;
import java.util.Arrays;

/**
* Type id resolver needed to support polymorphic (de)serialization of all kinds of
* {@link JsonSchema} instances.
* Note that to support custom types, you will need to sub-class this resolver
* and override at least {@link #idFromValue(Object)}, {@link #idFromValueAndType(Object, Class)} and
* and override at least {@link #idFromValue(DatabindContext, Object)}, {@link #idFromValueAndType(DatabindContext, Object, Class)} and
* {@link #typeFromId} methods; as well as associate this resolver using
* {@link com.fasterxml.jackson.annotation.JsonTypeInfo} annotation on
* all custom {@link JsonSchema} implementation classes.
Expand All @@ -29,16 +29,16 @@ public class JsonSchemaIdResolver extends TypeIdResolverBase
public JsonSchemaIdResolver() { }

@Override
public String idFromValue(Object value) {
public String idFromValue(DatabindContext ctxt, Object value) {
if (value instanceof JsonSchema) {
return ((JsonSchema)value).getType().value();
}
return null;
}

@Override
public String idFromValueAndType(Object value, Class<?> suggestedType) {
return idFromValue(value);
public String idFromValueAndType(DatabindContext ctxt, Object value, Class<?> suggestedType) {
return idFromValue(ctxt, value);
}

@Override
Expand Down Expand Up @@ -80,7 +80,7 @@ public Id getMechanism() {
public void init(JavaType baseType) { }

@Override
public String idFromBaseType() {
public String idFromBaseType(DatabindContext ctxt) {
return null;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.fasterxml.jackson.module.jsonSchema.annotation;
package tools.jackson.module.jsonSchema.jakarta.annotation;

import java.lang.annotation.*;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.fasterxml.jackson.module.jsonSchema.annotation;
package tools.jackson.module.jsonSchema.jakarta.annotation;

/**
* A link description object is used to describe link relations. In the
Expand Down
Loading