Class SchemaGenerator
java.lang.Object
com.github.victools.jsonschema.generator.SchemaGenerator
Generator for JSON Schema definitions via reflection based analysis of a given class.
-
Constructor Summary
ConstructorsConstructorDescriptionSchemaGenerator(SchemaGeneratorConfig config) Constructor.SchemaGenerator(SchemaGeneratorConfig config, TypeContext context) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionCreate aSchemaBuilderinstance for collecting schema references viacreateSchemaReference()until finalizing the generation viacollectDefinitions().tools.jackson.databind.node.ObjectNodegenerateSchema(Type mainTargetType, Type... typeParameters) Generate aJsonNodecontaining the JSON Schema representation of the given type.Returns theSchemaGeneratorConfigassociated with thisSchemaGenerator.
-
Constructor Details
-
SchemaGenerator
Constructor.- Parameters:
config- configuration to be applied
-
SchemaGenerator
Constructor.- Parameters:
config- configuration to be appliedcontext- type resolution/introspection context to be used during schema generations (across multiple schema generations)
-
-
Method Details
-
generateSchema
public tools.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
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. -
getConfig
Returns theSchemaGeneratorConfigassociated with thisSchemaGenerator.- Returns:
- a
SchemaGeneratorConfiginstance
-