class Rage::OpenAPI::Parsers::Ext::Alba::Visitor

def build_schema

def build_schema
  result = { "type" => "object" }
  result["properties"] = @schema if @schema.any?
  if @root_key_proc
    dynamic_root_key, dynamic_root_key_for_collection = @root_key_proc.call(@self_name)
    @root_key = dynamic_root_key
    @root_key_for_collection = dynamic_root_key_for_collection
  end
  if @is_collection
    result = if @collection_key && @root_key_for_collection
      { "type" => "object", "properties" => { @root_key_for_collection => { "type" => "object", "additionalProperties" => result }, **@meta } }
    elsif @collection_key
      { "type" => "object", "additionalProperties" => result }
    elsif @root_key_for_collection
      { "type" => "object", "properties" => { @root_key_for_collection => { "type" => "array", "items" => result }, **@meta } }
    else
      { "type" => "array", "items" => result }
    end
  elsif @root_key
    result = { "type" => "object", "properties" => { @root_key => result, **@meta } }
  end
  result = deep_transform_keys(result) if @key_transformer
  result
end