victools/jsonschema-generator
소개
Java JSON Schema 생성기 — Java 클래스에서 JSON Schema(Draft 6, Draft 7, Draft 2019-09 또는 Draft 2020-12)를 생성합니다.
개발 도구측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalJava JSON Schema Generator
Creating JSON Schema (Draft 6, Draft 7, Draft 2019-09 or Draft 2020-12) from your Java classes utilising Jackson.
This project consists of:
- the victools/jsonschema-generator (the only thing you need to get started)
- a few modules bundling standard configurations for your convenience:
- victools/jsonschema-module-jackson – deriving JSON Schema attributes from
jacksonannotations (e.g. "description", property name overrides, what properties to ignore) as well as looking up appropriate (annotated) subtypes - victools/jsonschema-module-jakarta-validation – deriving JSON Schema attributes from
jakarta.validation.constraintsannotations (e.g. which properties are nullable or not, their "minimum"/"maximum", "minItems"/"maxItems", "minLength"/"maxLength") - victools/jsonschema-module-javax-validation – deriving JSON Schema attributes from
javax.validationannotations (e.g. which properties are nullable or not, their "minimum"/"maximum", "minItems"/"maxItems", "minLength"/"maxLength") - victools/jsonschema-module-swagger-1.5 – deriving JSON Schema attributes from
swagger(1.5.x) annotations (e.g. "description", property name overrides, what properties to ignore, their "minimum"/"maximum", "const"/"enum") - victools/jsonschema-module-swagger-2 – deriving JSON Schema attributes from
swagger(2.x)@Schemaannotations
- victools/jsonschema-module-jackson – deriving JSON Schema attributes from
- the victools/jsonschema-maven-plugin – allowing you to generate JSON Schemas as part of your Maven build
Another example for such a module is:
- imIfOu/jsonschema-module-addon – deriving JSON Schema attributes from a custom annotation with various parameters, which is part of the module.
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 and configuration examples can be found here: https://victools.github.io/jsonschema-generator
Usage
Dependency (Maven)
<dependency>
<groupId>com.github.victools</groupId>
<artifactId>jsonschema-generator</artifactId>
<version>5.0.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.
It is discouraged to use an older/lower jsonschema-generator version than any of your jsonschema-module-* dependencies. If the module uses any feature only added to the jsonschema-generator in the newer version, runtime errors are to be expected.
Code
Complete/Minimal Example
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;
import tools.jackson.databind.JsonNode;
SchemaGeneratorConfigBuilder configBuilder = new SchemaGeneratorConfigBuilder(SchemaVersion.DRAFT_2020_12, OptionPreset.PLAIN_JSON);
SchemaGeneratorConfig config = configBuilder.build();
SchemaGenerator generator = new SchemaGenerator(config);
JsonNode jsonSchema = generator.generateSchema(YourClass.class);
System.out.println(jsonSchema.toPrettyString());
Additional examples can be found in the jsonschema-examples folder or throughout the various tests classes.
관련 프로젝트 살펴보기
불러오는 중…