Class SchemaBuilder
- java.lang.Object
-
- com.github.victools.jsonschema.generator.SchemaBuilder
-
public class SchemaBuilder extends Object
Builder for a single schema being generated.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.fasterxml.jackson.databind.node.ObjectNodecollectDefinitions(String designatedDefinitionPath)Completing the schema generation (aftercreateSchemaReference(Type, Type...)was invoked for all relevant types) by creating anObjectNodecontaining common schema definitions.com.fasterxml.jackson.databind.node.ObjectNodecreateSchemaReference(Type targetType, Type... typeParameters)Generate anObjectNodeplaceholder for the given type and add all referenced/encountered types to this builder instance.
-
-
-
Method Detail
-
createSchemaReference
public com.fasterxml.jackson.databind.node.ObjectNode createSchemaReference(Type targetType, Type... typeParameters)
Generate anObjectNodeplaceholder for the given type and add all referenced/encountered types to this builder instance.
This may be invoked multiple times (even for the same type) until the schema generation is being completed viacollectDefinitions(String).- Parameters:
targetType- type for which to generate the JSON Schema placeholdertypeParameters- optional type parameters (in case of themainTargetTypebeing a parameterised type)- Returns:
- JSON Schema placeholder (maybe be empty until
collectDefinitions(String)is being invoked) - See Also:
collectDefinitions(String)
-
collectDefinitions
public com.fasterxml.jackson.databind.node.ObjectNode collectDefinitions(String designatedDefinitionPath)
Completing the schema generation (aftercreateSchemaReference(Type, Type...)was invoked for all relevant types) by creating anObjectNodecontaining common schema definitions.The given definition path (e.g.
This should only be invoked once at the very end of the schema generation process."definitions","$defs","components/schemas") will be used in generated"$ref"values (e.g."#/definitions/YourType","#/$defs/YourType","#/components/schemas/YourType").- Parameters:
designatedDefinitionPath- the designated path to the returned definitions node, to be used in generated references- Returns:
- object node containing common schema definitions
- See Also:
createSchemaReference(Type, Type...)
-
-