-
Notifications
You must be signed in to change notification settings - Fork 1
/
api.default_api.rb
65 lines (59 loc) · 1.52 KB
/
api.default_api.rb
1
2
3
4
5
6
7
8
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
require 'json'
MyApp.add_route('GET', '/search', {
"resourcePath" => "/Default",
"summary" => "",
"nickname" => "search_get",
"responseClass" => "void",
"endpoint" => "/search",
"notes" => "e.g. /search?q=query-words",
"parameters" => [
{
"name" => "q",
"description" => "",
"dataType" => "String",
"allowableValues" => "",
"paramType" => "query",
},
{
"name" => "start",
"description" => "",
"dataType" => "Integer",
"allowableValues" => "",
"defaultValue" => "0",
"paramType" => "query",
},
{
"name" => "rows",
"description" => "",
"dataType" => "Integer",
"allowableValues" => "",
"defaultValue" => "10",
"paramType" => "query",
},
]}) do
cross_origin
# the guts live here
require 'uri'
require 'httpclient'
client = HTTPClient.new
@param_q = params.has_key?(:q) ? params[:q].to_str : "sccp"
url = URI::HTTPS.build({:host => "opm00h.u-aizu.ac.jp", :path => '/solr/api/v1/search', :query => "q=#{@param_q}&wt=json&site="})
ret = client.get(url)
@result = JSON.parse(ret.body)
output = erb :header
output += erb :main
output += erb :footer
end
MyApp.add_route('GET', '/.spec', {
"resourcePath" => "/Default",
"summary" => "",
"nickname" => "spec_get",
"responseClass" => "void",
"endpoint" => "/.spec",
"notes" => "providing the openapi schema YAML file.",
"parameters" => [
]}) do
cross_origin
# the guts live here
File.read("openapi.yaml")
end