swagui 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ae8af2d772ab074b0908b94ad69343fee386c75e
4
- data.tar.gz: 4bfab776b7a9fd1879a01f4d46348d15f85b47ca
3
+ metadata.gz: f93905b2767639de1c3eed8fd9204495bae20b6f
4
+ data.tar.gz: 41a1805fcd11d68db243d4bd850c44fc74a63270
5
5
  SHA512:
6
- metadata.gz: 1a149bce0d991e6e27e4e486d853ba30a4c86bd11d35610c4ebd7f40ba90c3b08fdfe0c28731f15eca9d28796bf9cd30465a91d62cab00768d0d876b78995181
7
- data.tar.gz: be3c49ba8d9600b6617248ddff1d95d6c36201bca825c1c8e3f8228a27947b81266fac297c83800c18ddcc2dc51717a6406295d8325eccc3e4938eaf492e5481
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
@@ -1,3 +1,3 @@
1
1
  module Swagui
2
- VERSION = "0.5.2"
2
+ VERSION = "0.5.3"
3
3
  end
@@ -5,30 +5,35 @@ module Swagui
5
5
 
6
6
  def initialize(app)
7
7
  @app = app
8
- @api_json_template = nil # used to store the template settings that applies to all apis
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
- response[1].merge!("Content-Type"=>"application/json") # response is always json content
15
-
16
- if yaml_response?(response) # yml response needs to be re=processed.
17
- body = []
18
- response[2].each do |f|
19
- body << YAML::load(f).tap do |response_hash|
20
- if response[2].path.end_with?('api-docs.yml')
21
- process_api_docs_api_listing(response_hash, response[2].path )
22
- else
23
- process_schemas(response_hash)
24
- process_base_path(response_hash, response[2].path, env)
25
- end
26
- end.to_json
27
- end
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
- response[2] = body
33
+ response[2] = [json_string]
30
34
 
31
- response[1].merge!("Content-Length"=> body.first.size.to_s)
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.2
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: 2014-12-31 00:00:00.000000000 Z
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.2.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.