Class DefaultJsonSchemaValidator

java.lang.Object
io.modelcontextprotocol.json.schema.jackson.DefaultJsonSchemaValidator
All Implemented Interfaces:
JsonSchemaValidator

public class DefaultJsonSchemaValidator extends Object implements JsonSchemaValidator
Default implementation of the JsonSchemaValidator interface. This class provides methods to validate structured content against a JSON schema. It uses the NetworkNT JSON Schema Validator library for validation.
Author:
Christian Tzolov
  • Constructor Details

    • DefaultJsonSchemaValidator

      public DefaultJsonSchemaValidator()
    • DefaultJsonSchemaValidator

      public DefaultJsonSchemaValidator(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
  • Method Details

    • validate

      public JsonSchemaValidator.ValidationResponse validate(Map<String,Object> schema, Object structuredContent)
      Specified by:
      validate in interface JsonSchemaValidator
    • generateCacheKey

      protected String generateCacheKey(Map<String,Object> schema)
      Generates a cache key for the given schema map.
      Parameters:
      schema - the schema map
      Returns:
      a cache key string
    • clearCache

      public void clearCache()
      Clears the schema cache. Useful for testing or memory management.
    • getCacheSize

      public int getCacheSize()
      Returns the current size of the schema cache.
      Returns:
      the number of cached schemas