efigence-swagger_ui_wrapper 0.0.6 → 0.0.8

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: 8328e38dfc300bd94b351cf52fa96caa38275c86
4
- data.tar.gz: adfc05e32a1007d910237507209d7487146014c4
3
+ metadata.gz: 78e9c2afab2e111e3e049d8f95b64cf89a7d5f3f
4
+ data.tar.gz: 4568a5d126d873e2d046f097ef68c882147c2356
5
5
  SHA512:
6
- metadata.gz: 0e4d88572179d67e83f1c0e86dfa95d24e105519abe6a52507ff5496b2f5f7deab17c9324748b2dcb32e9473823a5b57720241fbe41ca2fa688b46f74413386d
7
- data.tar.gz: cb79e7b19615cf63b02ba4818eb882d1ac748db2a8f969d0867524005000e18608373e4ccb06e83c90f137a6aa526ce627b0cd81a4b6d63e8b603ebd315798e8
6
+ metadata.gz: c921ff3ca672079c41b7e6a7cf986f0cb58e09e3b43e669c3f9c5305debaaf3d1fc338aef7c41876a8bbd11446323d475e7dad9e612ce706e6cc7c84a5f08076
7
+ data.tar.gz: d54fb30251f69dbc00ce5c2b48c3fe1e44e2c835c9785724dda86ba332bb8d307c554949fef5ee037e4bb425f8dd52539b8081f544c860c02be3eb14702f33dd
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
14
14
  spec.license = "MIT"
15
15
 
16
16
  # spec.files = `git ls-files -z`.split("\x0")
17
- spec.files = [".gitignore", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "efigence-swagger_ui_wrapper.gemspec", "lib/swagger_ui_wrapper.rb", "lib/swagger_ui_wrapper/rack/middleware.rb", "lib/swagger_ui_wrapper/version.rb", "vendor/assets/swagger/css/print.css", "vendor/assets/swagger/css/reset.css", "vendor/assets/swagger/css/screen.css", "vendor/assets/swagger/css/style.css", "vendor/assets/swagger/css/typography.css", "vendor/assets/swagger/fonts/DroidSans-Bold.ttf", "vendor/assets/swagger/fonts/DroidSans.ttf", "vendor/assets/swagger/images/collapse.gif", "vendor/assets/swagger/images/expand.gif", "vendor/assets/swagger/images/explorer_icons.png", "vendor/assets/swagger/images/favicon-16x16.png", "vendor/assets/swagger/images/favicon-32x32.png", "vendor/assets/swagger/images/favicon.ico", "vendor/assets/swagger/images/logo_small.png", "vendor/assets/swagger/images/pet_store_api.png", "vendor/assets/swagger/images/throbber.gif", "vendor/assets/swagger/images/wordnik_api.png", "vendor/assets/swagger/index.html", "vendor/assets/swagger/lang/en.js", "vendor/assets/swagger/lang/es.js", "vendor/assets/swagger/lang/fr.js", "vendor/assets/swagger/lang/geo.js", "vendor/assets/swagger/lang/it.js", "vendor/assets/swagger/lang/ja.js", "vendor/assets/swagger/lang/pl.js", "vendor/assets/swagger/lang/pt.js", "vendor/assets/swagger/lang/ru.js", "vendor/assets/swagger/lang/tr.js", "vendor/assets/swagger/lang/translator.js", "vendor/assets/swagger/lang/zh-cn.js", "vendor/assets/swagger/lib/backbone-min.js", "vendor/assets/swagger/lib/handlebars-2.0.0.js", "vendor/assets/swagger/lib/highlight.9.1.0.pack.js", "vendor/assets/swagger/lib/highlight.9.1.0.pack_extended.js", "vendor/assets/swagger/lib/jquery-1.8.0.min.js", "vendor/assets/swagger/lib/jquery.ba-bbq.min.js", "vendor/assets/swagger/lib/jquery.slideto.min.js", "vendor/assets/swagger/lib/jquery.wiggle.min.js", "vendor/assets/swagger/lib/js-yaml.min.js", "vendor/assets/swagger/lib/jsoneditor.min.js", "vendor/assets/swagger/lib/lodash.min.js", "vendor/assets/swagger/lib/marked.js", "vendor/assets/swagger/lib/swagger-oauth.js", "vendor/assets/swagger/o2c.html", "vendor/assets/swagger/swagger-ui.js", "vendor/assets/swagger/swagger-ui.min.js"]
17
+ spec.files = [".gitignore", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "efigence-swagger_ui_wrapper.gemspec", "lib/swagger_ui_wrapper.rb", "lib/swagger_ui_wrapper/rack/middleware.rb", "lib/swagger_ui_wrapper/version.rb", "vendor/assets/swagger/css/print.css", "vendor/assets/swagger/css/reset.css", "vendor/assets/swagger/css/screen.css", "vendor/assets/swagger/css/style.css", "vendor/assets/swagger/css/typography.css", "vendor/assets/swagger/fonts/DroidSans-Bold.ttf", "vendor/assets/swagger/fonts/DroidSans.ttf", "vendor/assets/swagger/images/collapse.gif", "vendor/assets/swagger/images/expand.gif", "vendor/assets/swagger/images/explorer_icons.png", "vendor/assets/swagger/images/favicon-16x16.png", "vendor/assets/swagger/images/favicon-32x32.png", "vendor/assets/swagger/images/favicon.ico", "vendor/assets/swagger/images/logo_small.png", "vendor/assets/swagger/images/pet_store_api.png", "vendor/assets/swagger/images/throbber.gif", "vendor/assets/swagger/images/wordnik_api.png", "vendor/assets/swagger/v1.html", "vendor/assets/swagger/v2.html", "vendor/assets/swagger/lang/en.js", "vendor/assets/swagger/lang/es.js", "vendor/assets/swagger/lang/fr.js", "vendor/assets/swagger/lang/geo.js", "vendor/assets/swagger/lang/it.js", "vendor/assets/swagger/lang/ja.js", "vendor/assets/swagger/lang/pl.js", "vendor/assets/swagger/lang/pt.js", "vendor/assets/swagger/lang/ru.js", "vendor/assets/swagger/lang/tr.js", "vendor/assets/swagger/lang/translator.js", "vendor/assets/swagger/lang/zh-cn.js", "vendor/assets/swagger/lib/backbone-min.js", "vendor/assets/swagger/lib/handlebars-2.0.0.js", "vendor/assets/swagger/lib/highlight.9.1.0.pack.js", "vendor/assets/swagger/lib/highlight.9.1.0.pack_extended.js", "vendor/assets/swagger/lib/jquery-1.8.0.min.js", "vendor/assets/swagger/lib/jquery.ba-bbq.min.js", "vendor/assets/swagger/lib/jquery.slideto.min.js", "vendor/assets/swagger/lib/jquery.wiggle.min.js", "vendor/assets/swagger/lib/js-yaml.min.js", "vendor/assets/swagger/lib/jsoneditor.min.js", "vendor/assets/swagger/lib/lodash.min.js", "vendor/assets/swagger/lib/marked.js", "vendor/assets/swagger/lib/swagger-oauth.js", "vendor/assets/swagger/o2c.html", "vendor/assets/swagger/swagger-ui.js", "vendor/assets/swagger/swagger-ui.min.js"]
18
18
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
20
  spec.require_paths = ["lib"]
@@ -6,18 +6,26 @@ module SwaggerUiWrapper
6
6
  class MiddleWare
7
7
  def initialize(app, options)
8
8
  @app = app
9
- @api_url_base = options[:api_url_base]
9
+ @api_url_base = options[:api_url_base] # http://test-server.com
10
10
  @path = options[:path] || '/swagger/'
11
11
  swagger_path = File.expand_path('../../../vendor/assets', File.dirname(__FILE__))
12
12
  @swagger_assets_handler = ::Rack::Static.new @app, root: swagger_path,
13
- urls: ['/swagger'],
14
- index: 'index.html'
13
+ urls: ['/swagger'] #,
14
+ # index: 'v1.html' # switched to redirect instead of render
15
15
  end
16
16
 
17
17
  def call(env)
18
18
  if env['REQUEST_PATH'] && env['REQUEST_PATH'].start_with?(@path)
19
- _env = env.merge("QUERY_STRING" => "url=http://localhost:9292/v1/swagger_doc")
20
- @swagger_assets_handler.call(_env)
19
+ if env['REQUEST_PATH'] == '/swagger/'
20
+ [302, {'Content-Type' => 'text',
21
+ 'Location' => (@api_url_base || (env['rack.url_scheme'] + "://" + env["HTTP_HOST"].to_s)) + @path + 'v1.html',
22
+ 'Content-Type' => 'text/html; charset=UTF-8'}, ['302 found']]
23
+ else
24
+ # some hack for GRAPE:
25
+ # _env = env.merge("QUERY_STRING" => "url=http://localhost:9292/v1/swagger_doc")
26
+ # @swagger_assets_handler.call(_env)
27
+ @swagger_assets_handler.call(env)
28
+ end
21
29
  else
22
30
  @app.call(env)
23
31
  end
@@ -1,3 +1,3 @@
1
1
  module SwaggerUiWrapper
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -95,6 +95,8 @@
95
95
  <div class='input'><input placeholder="http://example.com/api" id="input_baseUrl" name="baseUrl" type="text"/></div>
96
96
  <div id='auth_container'></div>
97
97
  <div class='input'><a id="explore" class="header__btn" href="#" data-sw-translate>Explore</a></div>
98
+ <a href='/swagger/v1.html'>V1</a>
99
+ <a href='/swagger/v2.html'>V2</a>
98
100
  </form>
99
101
  </div>
100
102
  </div>
@@ -0,0 +1,107 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>Swagger UI</title>
6
+ <link rel="icon" type="image/png" href="images/favicon-32x32.png" sizes="32x32" />
7
+ <link rel="icon" type="image/png" href="images/favicon-16x16.png" sizes="16x16" />
8
+ <link href='css/typography.css' media='screen' rel='stylesheet' type='text/css'/>
9
+ <link href='css/reset.css' media='screen' rel='stylesheet' type='text/css'/>
10
+ <link href='css/screen.css' media='screen' rel='stylesheet' type='text/css'/>
11
+ <link href='css/reset.css' media='print' rel='stylesheet' type='text/css'/>
12
+ <link href='css/print.css' media='print' rel='stylesheet' type='text/css'/>
13
+ <script src='lib/jquery-1.8.0.min.js' type='text/javascript'></script>
14
+ <script src='lib/jquery.slideto.min.js' type='text/javascript'></script>
15
+ <script src='lib/jquery.wiggle.min.js' type='text/javascript'></script>
16
+ <script src='lib/jquery.ba-bbq.min.js' type='text/javascript'></script>
17
+ <script src='lib/handlebars-2.0.0.js' type='text/javascript'></script>
18
+ <script src='lib/js-yaml.min.js' type='text/javascript'></script>
19
+ <script src='lib/lodash.min.js' type='text/javascript'></script>
20
+ <script src='lib/backbone-min.js' type='text/javascript'></script>
21
+ <script src='swagger-ui.js' type='text/javascript'></script>
22
+ <script src='lib/highlight.9.1.0.pack.js' type='text/javascript'></script>
23
+ <script src='lib/highlight.9.1.0.pack_extended.js' type='text/javascript'></script>
24
+ <script src='lib/jsoneditor.min.js' type='text/javascript'></script>
25
+ <script src='lib/marked.js' type='text/javascript'></script>
26
+ <script src='lib/swagger-oauth.js' type='text/javascript'></script>
27
+
28
+ <!-- Some basic translations -->
29
+ <!-- <script src='lang/translator.js' type='text/javascript'></script> -->
30
+ <!-- <script src='lang/ru.js' type='text/javascript'></script> -->
31
+ <!-- <script src='lang/en.js' type='text/javascript'></script> -->
32
+
33
+ <script type="text/javascript">
34
+ $(function () {
35
+ var url = window.location.search.match(/url=([^&]+)/);
36
+ if (url && url.length > 1) {
37
+ url = decodeURIComponent(url[1]);
38
+ } else {
39
+ url = '/api/v2/api-docs.json'; // "http://petstore.swagger.io/v2/swagger.json";
40
+ }
41
+
42
+ hljs.configure({
43
+ highlightSizeThreshold: 5000
44
+ });
45
+
46
+ // Pre load translate...
47
+ if(window.SwaggerTranslator) {
48
+ window.SwaggerTranslator.translate();
49
+ }
50
+ window.swaggerUi = new SwaggerUi({
51
+ url: url,
52
+ dom_id: "swagger-ui-container",
53
+ supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
54
+ onComplete: function(swaggerApi, swaggerUi){
55
+ if(typeof initOAuth == "function") {
56
+ initOAuth({
57
+ clientId: "your-client-id",
58
+ clientSecret: "your-client-secret-if-required",
59
+ realm: "your-realms",
60
+ appName: "your-app-name",
61
+ scopeSeparator: ",",
62
+ additionalQueryStringParams: {}
63
+ });
64
+ }
65
+
66
+ if(window.SwaggerTranslator) {
67
+ window.SwaggerTranslator.translate();
68
+ }
69
+ },
70
+ onFailure: function(data) {
71
+ log("Unable to Load SwaggerUI");
72
+ },
73
+ docExpansion: "none",
74
+ jsonEditor: false,
75
+ defaultModelRendering: 'schema',
76
+ showRequestHeaders: false
77
+ });
78
+
79
+ window.swaggerUi.load();
80
+
81
+ function log() {
82
+ if ('console' in window) {
83
+ console.log.apply(console, arguments);
84
+ }
85
+ }
86
+ });
87
+ </script>
88
+ </head>
89
+
90
+ <body class="swagger-section">
91
+ <div id='header'>
92
+ <div class="swagger-ui-wrap">
93
+ <a id="logo" href="http://swagger.io"><img class="logo__img" alt="swagger" height="30" width="30" src="images/logo_small.png" /><span class="logo__title">swagger</span></a>
94
+ <form id='api_selector'>
95
+ <div class='input'><input placeholder="http://example.com/api" id="input_baseUrl" name="baseUrl" type="text"/></div>
96
+ <div id='auth_container'></div>
97
+ <div class='input'><a id="explore" class="header__btn" href="#" data-sw-translate>Explore</a></div>
98
+ <a href='/swagger/v1.html'>V1</a>
99
+ <a href='/swagger/v2.html'>V2</a>
100
+ </form>
101
+ </div>
102
+ </div>
103
+
104
+ <div id="message-bar" class="swagger-ui-wrap" data-sw-translate>&nbsp;</div>
105
+ <div id="swagger-ui-container" class="swagger-ui-wrap"></div>
106
+ </body>
107
+ </html>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: efigence-swagger_ui_wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - lizhe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-11 00:00:00.000000000 Z
11
+ date: 2016-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -85,7 +85,6 @@ files:
85
85
  - vendor/assets/swagger/images/pet_store_api.png
86
86
  - vendor/assets/swagger/images/throbber.gif
87
87
  - vendor/assets/swagger/images/wordnik_api.png
88
- - vendor/assets/swagger/index.html
89
88
  - vendor/assets/swagger/lang/en.js
90
89
  - vendor/assets/swagger/lang/es.js
91
90
  - vendor/assets/swagger/lang/fr.js
@@ -114,6 +113,8 @@ files:
114
113
  - vendor/assets/swagger/o2c.html
115
114
  - vendor/assets/swagger/swagger-ui.js
116
115
  - vendor/assets/swagger/swagger-ui.min.js
116
+ - vendor/assets/swagger/v1.html
117
+ - vendor/assets/swagger/v2.html
117
118
  homepage: ''
118
119
  licenses:
119
120
  - MIT