Interface JsonSchemaFactory<T>

Type Parameters:
T - the source representation type
All Known Implementing Classes:
Jackson3JsonFactory, JacksonNodeJsonFactory, JacksonObjectJsonFactory

public interface JsonSchemaFactory<T>
Creates a JsonSchema from a source representation, validating it in the process.

Unlike JsonSchema.of(String), which wraps a string without inspecting it, a factory implementation parses source and rejects malformed JSON.

Discoverable via ServiceLoader: implementations register themselves in META-INF/services/dev.tachyonmcp.api.json.spi.JsonSchemaFactory, self-reporting the source type they accept through sourceType() so JsonSchema.from(Object, Class) can resolve the right provider for a given type.

Author:
Konstantin Pavlov
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the source type this factory accepts.
    toJsonSchema(T source)
    Creates a schema from source.
  • Method Details

    • sourceType

      Class<T> sourceType()
      Returns the source type this factory accepts.
      Returns:
      the source type
    • toJsonSchema

      JsonSchema toJsonSchema(T source)
      Creates a schema from source.
      Parameters:
      source - the source representation
      Returns:
      the parsed schema
      Throws:
      IllegalArgumentException - if source is not valid JSON