Module: Rails::Swagger::Controller

Defined in:
lib/rails/swagger/controller.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

Injects swagger-related code into the controller when included



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rails/swagger/controller.rb', line 6

def self.included base

  # Add controller hooks
  base.class_eval do
    before_action :validate_swagger_params
  end

  # Returns the swagger spec definition for the endpoint serving
  # the current request.
  def swagger_endpoint
    key = "#{params[:controller]}##{params[:action]}"
    endpoint = rails_swagger_engine.endpoints[key]
  end

  # Validates request parameters against the Swagger API spec
  # associated with this controller.
  def validate_swagger_params
    #puts swagger_endpoint.inspect.white
  end

end

Instance Method Details

#swagger_endpointObject

Returns the swagger spec definition for the endpoint serving the current request.



15
16
17
18
# File 'lib/rails/swagger/controller.rb', line 15

def swagger_endpoint
  key = "#{params[:controller]}##{params[:action]}"
  endpoint = rails_swagger_engine.endpoints[key]
end

#validate_swagger_paramsObject

Validates request parameters against the Swagger API spec associated with this controller.



22
23
24
# File 'lib/rails/swagger/controller.rb', line 22

def validate_swagger_params
  #puts swagger_endpoint.inspect.white
end