Skip to content
This repository has been archived by the owner on Apr 7, 2020. It is now read-only.

Module for the jsonschema-generator – Template

License

Notifications You must be signed in to change notification settings

victools/jsonschema-module-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Java JSON Schema Generator – Module Template

Build Status Maven Central

Module for the jsonschema-generator – Template

Features

  1. Provide base repository for creating jsonschema-generator module libraries.
  2. Describe fake template module.

Usage

Dependency (Maven)

<dependency>
    <groupId>com.github.victools</groupId>
    <artifactId>jsonschema-module-template</artifactId>
    <version>n/a</version>
</dependency>

Code

Passing into SchemaGeneratorConfigBuilder.with(Module)

import com.github.victools.jsonschema.generator.SchemaGeneratorConfigBuilder;
import com.github.victools.jsonschema.module.template.TemplateModule;
TemplateModule module = new TemplateModule();
SchemaGeneratorConfigBuilder configBuilder = new SchemaGeneratorConfigBuilder(objectMapper)
    .with(module);

Complete Example

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
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.module.template.TemplateModule;
ObjectMapper objectMapper = new ObjectMapper();
TemplateModule module = new TemplateModule();
SchemaGeneratorConfigBuilder configBuilder = new SchemaGeneratorConfigBuilder(objectMapper, OptionPreset.PLAIN_JSON)
    .with(module);
SchemaGeneratorConfig config = configBuilder.build();
SchemaGenerator generator = new SchemaGenerator(config);
JsonNode jsonSchema = generator.generateSchema(YourClass.class);

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

About

Module for the jsonschema-generator – Template

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages