Class: JsonapiSwaggerHelpers::IndexAction

Inherits:
Object
  • Object
show all
Includes:
Readable
Defined in:
lib/jsonapi_swagger_helpers/index_action.rb

Instance Method Summary collapse

Methods included from Readable

#all_tags, #default_description, #each_association, #each_stat, #full_description, #has_extra_fields?, #has_sideloads?, #include_directive, included, #initialize, #jsonapi_type, #operation_id, #payload_tags, #util

Instance Method Details

#action_nameObject



5
6
7
# File 'lib/jsonapi_swagger_helpers/index_action.rb', line 5

def action_name
  :index
end

#generateObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/jsonapi_swagger_helpers/index_action.rb', line 9

def generate
  _self = self

  @node.operation :get do
    key :description, _self.full_description
    key :operationId, _self.operation_id
    key :tags, _self.all_tags

    _self.util.jsonapi_sorting(self)
    _self.util.jsonapi_pagination(self)

    _self.util.each_filter(_self.resource) do |filter_label|
      _self.util.jsonapi_filter(self, filter_label)
    end

    _self.each_stat do |stat_name, calculations|
      _self.util.jsonapi_stat(self, stat_name, calculations)
    end

    _self.util.jsonapi_fields(self, _self.jsonapi_type)

    if _self.has_extra_fields?
      _self.util.jsonapi_extra_fields(self, _self.resource)
    end

    if _self.has_sideloads?
      _self.util.jsonapi_includes(self)

      _self.each_association do |association_name, association_resource|
        _self.util.each_filter(association_resource, association_name) do |filter_label|
          _self.util.jsonapi_filter(self, filter_label)
          _self.util.jsonapi_fields(self, association_resource.config[:type])
        end
      end
    end
  end
end