json-schema

json-schema generator for the JVM.

Лицензия

Лицензия

Категории

Категории

JSON Данные
Группа

Группа

com.mercateo
Идентификатор

Идентификатор

json-schema
Последняя версия

Последняя версия

0.2.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

json-schema
json-schema generator for the JVM.
Ссылка на сайт

Ссылка на сайт

https://github.com/mercateo/json-schema
Система контроля версий

Система контроля версий

https://github.com/mercateo/json-schema

Скачать json-schema

Как подключить последнюю версию

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

Зависимости

runtime (7)

Идентификатор библиотеки Тип Версия
com.googlecode.gentyref : gentyref jar 1.2.0
com.fasterxml.jackson.core : jackson-annotations jar 2.11.4
com.fasterxml.jackson.core : jackson-databind jar 2.11.4
org.slf4j : slf4j-api jar 1.7.30
javax.validation : validation-api jar 2.0.1.Final
org.jetbrains.kotlin : kotlin-stdlib jar 1.4.32
org.jetbrains.kotlin : kotlin-reflect jar 1.4.32

test (8)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.13
org.assertj : assertj-core jar 3.16.1
io.mockk : mockk jar 1.10.0
org.openjdk.jmh : jmh-core jar 1.25
org.openjdk.jmh : jmh-generator-annprocess jar 1.25
ch.qos.logback : logback-classic jar 1.2.3
org.jetbrains.kotlin : kotlin-test jar 1.4.32
org.hibernate : hibernate-validator jar 6.1.5.Final

Модули Проекта

Данный проект не имеет модулей.

json-schema

Codacy Badge Build Status Coverage Status MavenCentral

Generic JSON-Schema generator.

Features

  • Handles Generics
  • Configurable
  • Supports dynamic schema with allowed values and default values

Example

    SchemaGenerator schemaGenerator = new SchemaGenerator(
            Collections.emptyList(),
            Collections.<RawPropertyCollector>singletonList(new FieldCollector()),
            new HashMap<>());
    
    ObjectNode schema = schemaGenerator.generateSchema(Foo.class);
    
    String schemaString = schema.toString();

Generates the following result:

{
  "type": "object", 
  "properties": {
    "baz": {
      "type": "object", 
      "properties": {
        "qux": {
          "type": "string"
        }
      }
    }, 
    "bar": {
      "type": "string"
    }
  }
}}

Property structure

class Foo {
    String bar;
    Baz baz;
}

class Baz {
    String qux;
}

bar, baz and qux are properties.

Property representation

Properties are represented as Property Objects specified by containing and contained type:

Property<Foo, String> bar;
Property<Foo, Baz> baz;
Property<Baz, String> qux;

The part of the property which is represented by its type is contained in a PropertyDescriptor which has a generic type representing its contained type.

Property unwrapping

class Foo {
    String bar;
    
    @JsonUnwrapped
    Baz baz;
}

class Baz {
    String qux;
}
Property<Foo, String> bar;
Property<Foo, String> qux;

Benchmarks

current results

Benchmark                         Mode  Cnt        Score       Error  Units
Benchmarks.createRepeatedSchema  thrpt   10  1818545.697 ± 38533.578  ops/s
Benchmarks.createSchema          thrpt   10   260946.251 ± 15201.070  ops/s

createSchema creates SchemaGenerator and schema for each iteration, createdRepeatedSchema uses caching in the SchemaGenerator for schema creation

com.mercateo
the procurement platform for your business

Версии библиотеки

Версия
0.2.0
0.1.12
0.1.11
0.1.10
0.1.9
0.1.8
0.1.7
0.1.6
0.1.5
0.1.4
0.1.3
0.1.2
0.1.1
0.1.0