Implement OpenAPI document level modules
Overview
Create the top-level OpenAPI document models that represent the overall structure of an OpenAPI specification. These models are relatively simple but essential for organizing the generated specification.
Many of these fields will be defined from the user-defined configuration.rb which can be set at Rails initializer time.
-
OpenAPIDocument model represents the root document structure -
Info model handles API metadata (title, version, description, contact, license) -
Server model represents server configurations -
Components model organizes reusable components (schemas, security schemes) -
Models validate required fields per OpenAPI 3.0 spec
Example document
class OpenAPIDocument < BaseModel
attr_accessor :openapi, :info, :servers, :paths, :components, :security, :tags
def initialize
@openapi = "3.0.0"
@paths = {}
@components = Components.new
end
def to_h
{
openapi: openapi,
info: info.to_h,
servers: servers&.map(&:to_h),
paths: paths,
components: components.to_h
}.compact
end
end
Edited by 🤖 GitLab Bot 🤖