Class: SwaggerApi::Operations::Create

Inherits:
Base
  • Object
show all
Defined in:
lib/swagger_api/operations/create.rb

Instance Attribute Summary

Attributes inherited from Base

#action, #controller

Instance Method Summary collapse

Methods inherited from Base

#model, #model_name, #parameters, #readable_action, #responses

Instance Method Details

#createObject



4
5
6
7
8
9
# File 'lib/swagger_api/operations/create.rb', line 4

def create
  create = super
  create[:requestBody] = request_body
  create.delete(:parameters)
  create
end

#error_responsesObject



32
33
34
35
36
# File 'lib/swagger_api/operations/create.rb', line 32

def error_responses
  super.reject do |error_response|
    %w(404).include?(error_response.keys.first)
  end
end

#request_bodyObject



11
12
13
14
15
# File 'lib/swagger_api/operations/create.rb', line 11

def request_body
  {
    "$ref" => "#/components/requestBodies/#{model_name}"
  }
end

#success_responseObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/swagger_api/operations/create.rb', line 17

def success_response
  {
    '303' => {
      description: "#{readable_action} #{model_name.downcase}'s information",
      headers: {
        Location: {
          schema: {
            type: :string
          }
        }
      }
    }
  }
end