Class SchemaGenerator
- java.lang.Object
-
- com.github.victools.jsonschema.generator.SchemaGenerator
-
public class SchemaGenerator extends Object
Generator for JSON Schema definitions via reflection based analysis of a given class.
-
-
Constructor Summary
Constructors Constructor Description SchemaGenerator(SchemaGeneratorConfig config)Constructor.SchemaGenerator(SchemaGeneratorConfig config, TypeContext context)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SchemaBuilderbuildMultipleSchemaDefinitions()Create aSchemaBuilderinstance for collecting schema references viacreateSchemaReference()until finalizing the generation viacollectDefinitions().com.fasterxml.jackson.databind.node.ObjectNodegenerateSchema(Type mainTargetType, Type... typeParameters)Generate aJsonNodecontaining the JSON Schema representation of the given type.SchemaGeneratorConfiggetConfig()Returns theSchemaGeneratorConfigassociated with thisSchemaGenerator.
-
-
-
Constructor Detail
-
SchemaGenerator
public SchemaGenerator(SchemaGeneratorConfig config)
Constructor.- Parameters:
config- configuration to be applied
-
SchemaGenerator
public SchemaGenerator(SchemaGeneratorConfig config, TypeContext context)
Constructor.- Parameters:
config- configuration to be appliedcontext- type resolution/introspection context to be used during schema generations (across multiple schema generations)
-
-
Method Detail
-
generateSchema
public com.fasterxml.jackson.databind.node.ObjectNode generateSchema(Type mainTargetType, Type... typeParameters)
Generate aJsonNodecontaining the JSON Schema representation of the given type.- Parameters:
mainTargetType- type for which to generate the JSON SchematypeParameters- optional type parameters (in case of themainTargetTypebeing a parameterised type)- Returns:
- generated JSON Schema
-
buildMultipleSchemaDefinitions
public SchemaBuilder buildMultipleSchemaDefinitions()
Create aSchemaBuilderinstance for collecting schema references viacreateSchemaReference()until finalizing the generation viacollectDefinitions().
This is intended when you want to create a document that includes JSON Schema definitions but is not a JSON Schema itself, e.g. creating model descriptions for an OpenAPI definition.- Returns:
SchemaBuilderinstance- See Also:
: adding a single type to the builder instance,: generate an listing the common schema definitions
-
getConfig
public SchemaGeneratorConfig getConfig()
Returns theSchemaGeneratorConfigassociated with thisSchemaGenerator.- Returns:
- a
SchemaGeneratorConfiginstance
-
-