swagui 0.5.2 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/swagui/swagger_doc_handler.rb +1 -1
- data/lib/swagui/version.rb +1 -1
- data/lib/swagui/yaml_doc_handler.rb +22 -19
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f93905b2767639de1c3eed8fd9204495bae20b6f
|
4
|
+
data.tar.gz: 41a1805fcd11d68db243d4bd850c44fc74a63270
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18acef64223455a80559eb4b765e22d9ade6c02b3e66c1cf939bdee7af87c4e7c1ffffd13bb96af07ef1b30f593df00748ed9bfaaa7e577f95453b10c0272a0c
|
7
|
+
data.tar.gz: d2152ee4c4701b68b6d527a4a4fac813b0329b901056f67c72287890addeef2567aec00496958cf1ecdbc1ec1b18ce54cff2bb8935c251a9cf77e36c7a5fca6d
|
@@ -18,7 +18,7 @@ module Swagui
|
|
18
18
|
|
19
19
|
first_valid_file_response = ['', '.json', '.yml'].map do |ext|
|
20
20
|
@app_file_server.call(env.merge('PATH_INFO' => "#{path}#{ext}", 'REQUEST_METHOD' => 'GET'))
|
21
|
-
end.find {|res| res[0] == 200 }
|
21
|
+
end.find {|res| (res[0] == 200 || res[0] == 304) }
|
22
22
|
|
23
23
|
first_valid_file_response || [404, {"Content-Type"=>"application/json"}, '']
|
24
24
|
end
|
data/lib/swagui/version.rb
CHANGED
@@ -5,30 +5,35 @@ module Swagui
|
|
5
5
|
|
6
6
|
def initialize(app)
|
7
7
|
@app = app
|
8
|
-
|
8
|
+
api_docs_content = @app.call("REQUEST_METHOD"=>"GET", "PATH_INFO"=>"/api-docs.yml")
|
9
|
+
v = ''; api_docs_content[2].each {|x| v = v + x}
|
10
|
+
@api_json_template = YAML.load(v)['template'] # used to store the template settings that applies to all apis
|
9
11
|
end
|
10
12
|
|
11
13
|
def call(env)
|
12
14
|
@app.call(env).tap do |response|
|
15
|
+
if response[0] == 200
|
16
|
+
response[1].merge!("Content-Type"=>"application/json") # response is always json content
|
13
17
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
18
|
+
if yaml_response?(response) # yml response needs to be re=processed.
|
19
|
+
body = []
|
20
|
+
response[2].each do |f|
|
21
|
+
body << f
|
22
|
+
end
|
23
|
+
|
24
|
+
json_string = YAML::load(body.join('')).tap do |response_hash|
|
25
|
+
if response[2].path.end_with?('api-docs.yml')
|
26
|
+
process_api_docs_api_listing(response_hash, response[2].path )
|
27
|
+
else
|
28
|
+
process_schemas(response_hash)
|
29
|
+
process_base_path(response_hash, response[2].path, env)
|
30
|
+
end
|
31
|
+
end.to_json
|
28
32
|
|
29
|
-
|
33
|
+
response[2] = [json_string]
|
30
34
|
|
31
|
-
|
35
|
+
response[1].merge!("Content-Length"=> json_string.size.to_s)
|
36
|
+
end
|
32
37
|
end
|
33
38
|
end
|
34
39
|
end
|
@@ -82,8 +87,6 @@ module Swagui
|
|
82
87
|
def process_api_docs_api_listing(response_hash, doc_path)
|
83
88
|
if response_hash['models'].nil? # requesting the root
|
84
89
|
|
85
|
-
@api_json_template = response_hash.delete('template')
|
86
|
-
|
87
90
|
dir_path = File.dirname(doc_path)
|
88
91
|
files = Dir["#{File.dirname(doc_path)}/*.yml"].map {|x| x.gsub(dir_path, '').gsub('.yml', '')}
|
89
92
|
files.each do |file|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: swagui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jack Xu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -143,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
143
|
version: '0'
|
144
144
|
requirements: []
|
145
145
|
rubyforge_project:
|
146
|
-
rubygems_version: 2.
|
146
|
+
rubygems_version: 2.1.9
|
147
147
|
signing_key:
|
148
148
|
specification_version: 4
|
149
149
|
summary: A rack-based swagger-ui middleware and commandline utility.
|