Class: SwaggerApi::Operations::Index

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

Instance Attribute Summary

Attributes inherited from Base

#action, #controller

Instance Method Summary collapse

Methods inherited from Base

#create, #model, #model_name, #responses

Instance Method Details

#error_responsesObject



43
44
45
46
47
# File 'lib/swagger_api/operations/index.rb', line 43

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

#headersObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/swagger_api/operations/index.rb', line 4

def headers
  {
    'x-total' => {
      schema: {
        type: :integer
      },
      description: 'total results available',
    },
    'x-link-next' => {
      schema: {
        type: :string
      },
      description: 'uri for next page of results',
    },
  }
end

#parametersObject



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/swagger_api/operations/index.rb', line 21

def parameters
  columns.map do |column|
    {
      name: column.name,
      in: 'query',
      required: false,
      description: "#{column.name} of #{model.name}",
      schema: SwaggerApi::ColumnSchema.new(column: column).create,
    }
  end
end

#readable_actionObject



39
40
41
# File 'lib/swagger_api/operations/index.rb', line 39

def readable_action
  'list'
end

#success_responseObject



33
34
35
36
37
# File 'lib/swagger_api/operations/index.rb', line 33

def success_response
  success = super
  success['200'][:headers] = headers
  success
end