Class SchemaProvider2
java.lang.Object
uno.anahata.ai.tools.schema.SchemaProvider2
A clean, focused provider for generating OpenAPI/Swagger compliant JSON
schemas from Java types.
This provider's key feature is its deep, reflection-based analysis to enrich
the schema with precise Java type information, embedding the "beautiful"
fully qualified type name into the title field of every object,
property, and array item.
It correctly handles complex generic types and recursive data structures, and performs inlining to produce a single, self-contained schema object suitable for AI models (which often struggle with external references).
- Author:
- anahata-gemini-pro-2.5
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.fasterxml.jackson.databind.ObjectMapperThe Jackson ObjectMapper used for internal JSON processing and schema generation. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringGenerates a complete, inlined JSON schema for a given Java type.static StringgenerateInlinedSchemaString(Type wrapperType, String attributeName, Type wrappedType) Generates a complete, inlined JSON schema for a wrapper type, but with the schema for a specific 'result' type surgically injected into its 'result' property.
-
Field Details
-
OBJECT_MAPPER
public static final com.fasterxml.jackson.databind.ObjectMapper OBJECT_MAPPERThe Jackson ObjectMapper used for internal JSON processing and schema generation.
-
-
Constructor Details
-
SchemaProvider2
public SchemaProvider2()
-
-
Method Details
-
generateInlinedSchemaString
public static String generateInlinedSchemaString(Type wrapperType, String attributeName, Type wrappedType) throws com.fasterxml.jackson.core.JsonProcessingException Generates a complete, inlined JSON schema for a wrapper type, but with the schema for a specific 'result' type surgically injected into its 'result' property.- Parameters:
wrapperType- The container type (e.g., JavaMethodToolResponse.class).attributeName- The name of the property in the wrapper to replace.wrappedType- The specific type of the result to inject (e.g., Tree.class or void.class).- Returns:
- A complete, final JSON schema string.
- Throws:
com.fasterxml.jackson.core.JsonProcessingException- if schema generation fails.
-
generateInlinedSchemaString
public static String generateInlinedSchemaString(Type type) throws com.fasterxml.jackson.core.JsonProcessingException Generates a complete, inlined JSON schema for a given Java type. This method is used for generating schemas for tool parameters and simple return types.- Parameters:
type- The Java type to generate the schema for.- Returns:
- A complete, final JSON schema string, or
nullfor void types. - Throws:
com.fasterxml.jackson.core.JsonProcessingException- if schema generation fails.
-
