70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
# File 'lib/trample/swagger.rb', line 70
def trample_swagger(search_class, path)
swagger_path "#{path}/new" do
operation :get do
key :description, "Instantiate default search. See the corresponding PUT operation for valid inputs."
key :tags, ['search']
response 200 do
key :description, 'Trample response'
schema do
key :'$ref', :TrampleSearchResponse
end
end
end
end
swagger_path "#{path}/{id}" do
operation :put do
description = "<p>Trample search <a target='_blank' href='http://richmolj.github.io/trample'>View Full Trample Documentation</a></p><p><strong>Conditions:</strong></p><ul>"
search_class._conditions.each_pair do |name, condition|
attrs = condition.attributes.select { |k,v| !!v }.map { |k,v| k }
attrs.select! { |a| CONDITION_OPTION_WHITELIST.include?(a) }
attrs = attrs.present? ? "(#{attrs.join(', ')})" : ''
description << "<li>#{name} #{attrs}</li>"
end
description << "</ul>"
if search_class._aggs.present?
description << "<p><strong>Aggregations:</strong></p><ul>"
search_class._aggs.each_pair do |name, agg|
description << "<li>#{name}</li>"
end
description << "</ul>"
end
key :description, description
key :tags, ['search']
parameter paramType: :path do
key :name, :id
key :type, :integer
key :default, SecureRandom.uuid
end
parameter do
key :name, :data
key :in, :body
schema do
key :'$ref', :TrampleSearch
end
end
response 200 do
key :description, 'Trample response'
schema do
key :'$ref', :TrampleSearchResponse
end
end
end
end
end
|