Create generator orchestrator
Overview
Implement the main Generator class that coordinates all converters and assembles the final OpenAPI document. This is the core orchestration layer that ties all components together.
-
Generator class provides main generate method entry point -
Initializes and manages SchemaRegistry instance -
Coordinates all converters in proper sequence -
Assembles final OpenAPI document structure -
Merges converter outputs into cohesive spec -
Handles multiple Grape API classes -
Supports configuration options -
Returns valid OpenAPI 3.0 JSON
module GrapeOpenAPI
class Generator
def self.generate(api_classes, options = {})
new(api_classes, options).generate
end
def initialize(api_classes, options = {})
@api_classes = Array(api_classes)
@options = options
@registry = SchemaRegistry.new
end
def generate
# 1. Initialize document structure
# 2. Process each API class
# 3. Extract and convert paths
# 4. Build components from registry
# 5. Validate final document
# 6. Return OpenAPI hash
end
end
end
Required Output
{
openapi: "3.0.0",
info: { ... },
servers: [ ... ],
paths: { ... },
components: {
schemas: { ... },
securitySchemes: { ... }
}
}
This orchestrator will evolve as converters are added, but should establish the basic pipeline and document structure from the start.
Edited by 🤖 GitLab Bot 🤖