Class DefaultJsonSchemaValidator
java.lang.Object
io.modelcontextprotocol.json.schema.jackson.DefaultJsonSchemaValidator
- All Implemented Interfaces:
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
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.modelcontextprotocol.json.schema.JsonSchemaValidator
JsonSchemaValidator.ValidationResponse -
Constructor Summary
ConstructorsConstructorDescriptionDefaultJsonSchemaValidator(com.fasterxml.jackson.databind.ObjectMapper objectMapper) -
Method Summary
Modifier and TypeMethodDescriptionvoidClears the schema cache.protected StringgenerateCacheKey(Map<String, Object> schema) Generates a cache key for the given schema map.intReturns the current size of the schema cache.
-
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:
validatein interfaceJsonSchemaValidator
-
generateCacheKey
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
-