Class SchemaExtractorService

java.lang.Object
ai.pipestream.common.service.SchemaExtractorService

@ApplicationScoped public class SchemaExtractorService extends Object
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 Details

    • SchemaExtractorService

      public SchemaExtractorService()
  • Method Details

    • extractSchemaByName

      public Optional<String> extractSchemaByName(String schemaName)
      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

      public Optional<String> 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

      public Optional<String> 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

      public Optional<String> extractParserConfigSchema()
      Convenience method to extract the ParserConfig schema specifically.
      Returns:
      Optional containing ParserConfig schema as JSON string if found
    • extractParserConfigSchemaForValidation

      public Optional<String> 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

      public Optional<String> 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).
    • extractParserConfigSchemaResolvedForJsonForms

      public Optional<String> extractParserConfigSchemaResolvedForJsonForms()
      Convenience method for ParserConfig specifically.
    • extractSchemaForClass

      public Optional<String> extractSchemaForClass(Class<?> configClass)
      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

      public Optional<String> 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