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, #request_body, #responses

Instance Method Details

#error_responsesObject



46
47
48
49
50
# File 'lib/swagger_api/operations/index.rb', line 46

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

#headersObject



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

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



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

def parameters
  columns.map do |column|
    next if column.name.start_with?('encrypted_') || column.name.end_with?('_iv')
    {
      name: column.name,
      in: 'query',
      required: false,
      description: "#{column.name} of #{model.name}",
      schema: SwaggerApi::ColumnSchema.new(column: column).create
    }
  end.compact
end

#readable_actionObject



42
43
44
# File 'lib/swagger_api/operations/index.rb', line 42

def readable_action
  'list'
end

#success_responseObject



36
37
38
39
40
# File 'lib/swagger_api/operations/index.rb', line 36

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