Package ai.pipestream.common.service
Class SchemaExtractorService
java.lang.Object
ai.pipestream.common.service.SchemaExtractorService
Service for extracting OpenAPI schema components from the dynamically generated OpenAPI document.
This service provides a centralized way to access schema definitions for validation and registration.
Pattern established for chunker module and designed to be reused across all modules and services.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionConvenience method to extract the ChunkerConfig schema specifically.Extracts ChunkerConfig schema and cleans it for JSON Schema v7 validation.Convenience method to extract the ParserConfig schema specifically.Extracts ParserConfig schema and cleans it for JSON Schema v7 validation.Convenience method for ParserConfig specifically.extractSchemaByName(String schemaName) Extracts a specific schema component from the OpenAPI document by name.extractSchemaForClass(Class<?> configClass) Convenience method to extract any config schema by inferring the name from a class.extractSchemaResolvedForJsonForms(String schemaName) Extracts a schema and resolves OpenAPI $ref references against components.schemas, returning a JSON Schema object suitable for JSONForms rendering (no x-* extensions, inline referenced schemas).Gets the full OpenAPI document as a JSON string.booleanValidates that the OpenAPI document service is available and functional.
-
Constructor Details
-
SchemaExtractorService
public SchemaExtractorService()
-
-
Method Details
-
extractSchemaByName
Extracts a specific schema component from the OpenAPI document by name.- Parameters:
schemaName- The name of the schema to extract (e.g., "ChunkerConfig", "ParserConfig")- Returns:
- Optional containing the schema as JSON string if found, empty if not found
-
extractChunkerConfigSchema
Convenience method to extract the ChunkerConfig schema specifically. This is the proven pattern from our test cases.- Returns:
- Optional containing ChunkerConfig schema as JSON string if found
-
extractChunkerConfigSchemaForValidation
Extracts ChunkerConfig schema and cleans it for JSON Schema v7 validation. Removes OpenAPI-specific elements like $ref and x-hidden extensions.- Returns:
- Optional containing JSON Schema v7 compatible schema
-
extractParserConfigSchema
Convenience method to extract the ParserConfig schema specifically.- Returns:
- Optional containing ParserConfig schema as JSON string if found
-
extractParserConfigSchemaForValidation
Extracts ParserConfig schema and cleans it for JSON Schema v7 validation. Removes OpenAPI-specific elements like $ref and x-hidden extensions.- Returns:
- Optional containing JSON Schema v7 compatible schema
-
extractSchemaResolvedForJsonForms
Extracts a schema and resolves OpenAPI $ref references against components.schemas, returning a JSON Schema object suitable for JSONForms rendering (no x-* extensions, inline referenced schemas). -
extractParserConfigSchemaResolvedForJsonForms
Convenience method for ParserConfig specifically. -
extractSchemaForClass
Convenience method to extract any config schema by inferring the name from a class. Assumes the OpenAPI schema name matches the simple class name.- Parameters:
configClass- The configuration class (e.g., ChunkerConfig.class)- Returns:
- Optional containing the schema as JSON string if found
-
isOpenApiDocumentAvailable
public boolean isOpenApiDocumentAvailable()Validates that the OpenAPI document service is available and functional. Useful for health checks and startup validation.- Returns:
- true if the service is available and can generate an OpenAPI document
-
getFullOpenApiDocument
Gets the full OpenAPI document as a JSON string. Useful for debugging or providing the complete API specification.- Returns:
- Optional containing the full OpenAPI document as JSON string
-