Class: Symphonia::ApiController

Inherits:
ApplicationController show all
Includes:
Swagger::Blocks
Defined in:
app/controllers/symphonia/api_controller.rb

Constant Summary collapse

SWAGGERED_CLASSES =

A list of all classes that have swagger_* declarations.

[
  UsersController,
  User,
  Swagger::ErrorModel,
]

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ControllerExtensions

#admin_require, #authorize, #back_url, #current_user, #current_user_session, #handle_unverified_request, #login_require, #menu_item, #redirect_back_or_default, #redirect_to_referer_or, #render_403, #render_404, #render_api_head, #render_api_ok, #set_default_locale, #set_locale, #store_location

Class Method Details

.add_tag(name:, description:) ⇒ Object

Parameters:



50
51
52
# File 'app/controllers/symphonia/api_controller.rb', line 50

def self.add_tag(name:, description:)
  swagger_root_node.tag name: name, description: description
end

.api_description=(text) ⇒ Object

Parameters:



66
67
68
# File 'app/controllers/symphonia/api_controller.rb', line 66

def self.api_description=(text)
  swagger_root_node.data[:info].data[:description] = text
end

.api_title=(text) ⇒ Object

Parameters:



61
62
63
# File 'app/controllers/symphonia/api_controller.rb', line 61

def self.api_title=(text)
  swagger_root_node.data[:info].data[:title] = text
end

.for_documentationObject



44
45
46
# File 'app/controllers/symphonia/api_controller.rb', line 44

def self.for_documentation
  SWAGGERED_CLASSES + Symphonia::ApiController::SWAGGERED_CLASSES
end

.swagger_root_nodeSwagger::Blocks::Nodes::RootNode

Returns:

  • (Swagger::Blocks::Nodes::RootNode)


55
56
57
58
# File 'app/controllers/symphonia/api_controller.rb', line 55

def self.swagger_root_node
  node = Symphonia::ApiController.send(:_swagger_nodes)
  node[:root_node]
end

Instance Method Details

#indexObject



70
71
72
73
74
75
76
# File 'app/controllers/symphonia/api_controller.rb', line 70

def index
  json = ::Swagger::Blocks.build_root_json(self.class.for_documentation + [self.class])
  respond_to do |format|
    format.yaml { render plain: json.deep_stringify_keys.to_yaml }
    format.json { render json: json }
  end
end