class Swagger::Api::Operations::Base
Attributes
action[RW]
controller[RW]
Public Instance Methods
create()
click to toggle source
# File lib/swagger/api/operations/base.rb, line 10 def create { summary: "#{readable_action} #{model_name}", description: "#{readable_action} #{model_name.downcase}'s information", parameters: parameters, responses: responses, tags: [model_name] } end
error_responses()
click to toggle source
# File lib/swagger/api/operations/base.rb, line 61 def error_responses [ { '404' => { '$ref' => '#/components/responses/NotFound' } }, { '401' => { '$ref' => '#/components/responses/Unauthorized' } }, { '422' => { '$ref' => '#/components/responses/BadRequest' } }, { '500' => { '$ref' => '#/components/responses/Unexpected' } } ] end
model()
click to toggle source
# File lib/swagger/api/operations/base.rb, line 86 def model @model ||= model_name.constantize end
model_name()
click to toggle source
# File lib/swagger/api/operations/base.rb, line 82 def model_name @model_name ||= controller.model end
parameters()
click to toggle source
# File lib/swagger/api/operations/base.rb, line 21 def parameters [ { name: 'id', in: 'path', description: "ID of #{model_name}", required: true, schema: { type: :integer, format: :int64, minimum: 1 }, } ] end
readable_action()
click to toggle source
# File lib/swagger/api/operations/base.rb, line 78 def readable_action @readable_action ||= self.class.name.demodulize.downcase end
responses()
click to toggle source
# File lib/swagger/api/operations/base.rb, line 37 def responses return @responses unless @responses.nil? @responses = success_response error_responses.each do |error_response| @responses.merge!(error_response) end @responses end
success_response()
click to toggle source
# File lib/swagger/api/operations/base.rb, line 46 def success_response { '200' => { description: "#{readable_action} #{model_name.downcase}'s information", content: { 'application/json; charset=utf-8' => { schema: { '$ref' => "#/components/schemas/#{model_name}" } } } } } end