Class SchemaBuilder

java.lang.Object
com.github.victools.jsonschema.generator.SchemaBuilder

public class SchemaBuilder extends Object
Builder for a single schema being generated.
  • Method Details

    • createSchemaReference

      public tools.jackson.databind.node.ObjectNode createSchemaReference(Type targetType, Type... typeParameters)
      Generate an ObjectNode placeholder 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 via collectDefinitions(String).
      Parameters:
      targetType - type for which to generate the JSON Schema placeholder
      typeParameters - optional type parameters (in case of the mainTargetType being a parameterised type)
      Returns:
      JSON Schema placeholder (maybe be empty until collectDefinitions(String) is being invoked)
      See Also:
    • collectDefinitions

      public tools.jackson.databind.node.ObjectNode collectDefinitions(String designatedDefinitionPath)
      Completing the schema generation (after createSchemaReference(Type, Type...) was invoked for all relevant types) by creating an ObjectNode containing common schema definitions.

      The given definition path (e.g. "definitions", "$defs", "components/schemas") will be used in generated "$ref" values (e.g. "#/definitions/YourType", "#/$defs/YourType", "#/components/schemas/YourType").

      This should only be invoked once at the very end of the schema generation process.
      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: