Class: Rage::Configuration::OpenAPI

Inherits:
Object
  • Object
show all
Defined in:
lib/rage/configuration.rb

Instance Method Summary collapse

Instance Method Details

#tag_resolver#call?

Returns the OpenAPI tag resolver used by Rage.

Returns:

  • (#call, nil)


598
599
600
# File 'lib/rage/configuration.rb', line 598

def tag_resolver
  @tag_resolver
end

#tag_resolver=(tag_resolver) ⇒ Object

Specify the rules to customize how OpenAPI tags are generated for API operations. The method accepts a callable object that receives the controller class, the action name (as a symbol), and the original tag generated by Rage. The callable should return a string or an array of strings representing the tags to use for the API operation. This enables grouping endpoints in the OpenAPI documentation according to your application’s needs.

Examples:

Rage.configure do
  config.openapi.tag_resolver = proc do |controller_class, action_name, default_tag|
    if controller_class.name.start_with?("Admin::")
      [default_tag, "Admin"]
    else
      [default_tag, "Public"]
    end
  end
end

Parameters:

  • tag_resolver (#call)

    a callable object that resolves OpenAPI tags



588
589
590
591
592
593
594
# File 'lib/rage/configuration.rb', line 588

def tag_resolver=(tag_resolver)
  unless tag_resolver.respond_to?(:call)
    raise ArgumentError, "Custom tag resolver should respond to `#call`"
  end

  @tag_resolver = tag_resolver
end