grape-swagger-ui 0.1.0 → 0.1.1

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: c7e74c225b173b884858eff45aa6dda7b451d9bf
4
- data.tar.gz: 40ce002bcd5c185be1fc5ca2bbc11bea0101fe9c
3
+ metadata.gz: 177cfa3f40b4492ee4fef7ebc9f30c76cd06b990
4
+ data.tar.gz: 9c457aab5f44ddee97d7a9a63347ed63a04383ea
5
5
  SHA512:
6
- metadata.gz: 80a484beff310bd15f208ee157238b7f8a4f08e99fb7b44ee4627e10281a87d3786703a35772a943c9da6f89259235c3c1e14356ce337417e8cec9fe4ae941c0
7
- data.tar.gz: 7d49aacaf6fe37e28da760666ed11543a85bf75e461502e6814aff13f0c34f7b3c5aa68935e8503b82ac6ff72f8bb10b4d7ed3dc9f83dc030a5b3eadbef7979c
6
+ metadata.gz: 55dc4a15138b3b70af5809b07ce9e700e208c53a75622e34f5a4572187689c6bf962091c597e792b39c80d54903e28ddc0ce9e5fc2e13724c1eb8c3a266aaca8
7
+ data.tar.gz: b7f418eae47ff9458d0b2cd68b801b8b024517bfbab665fca11fe140eb0b74559982eee8f698cb2d37622bae54cc241c578116fd544814607c6430550a4a99f4
data/README.md CHANGED
@@ -49,9 +49,9 @@ else
49
49
 
50
50
  *Generate the main layout for customizations*
51
51
 
52
- rails generate swagger:layout
52
+ rails generate swagger:layout [TEMPLATE_ENGINE]
53
53
 
54
- and change the initializer.
54
+ and change the initializer. Currently supported: ERB, HAML, SLIM.
55
55
 
56
56
  Since this is a seperate layout and if you want to use this in your staging environment you need to precompile it.
57
57
 
@@ -14,7 +14,7 @@
14
14
  if (url && url.length > 1) {
15
15
  url = decodeURIComponent(url[1]);
16
16
  } else {
17
- url = "http://<%= request.host%>:<%=request.port%>/api/v1/swagger_doc";
17
+ url = "<%= request.protocol %><%= request.host%>:<%=request.port%>/api/v1/swagger_doc";
18
18
  }
19
19
 
20
20
  hljs.configure({
@@ -2,13 +2,14 @@ module Swagger
2
2
  module Generators
3
3
  class LayoutGenerator < ::Rails::Generators::Base
4
4
  desc 'Setup a dedicated layout for the swagger-ui'
5
+ argument :template_engine, :type => :string, :default => "erb"
5
6
 
6
7
  def self.source_root
7
8
  File.expand_path('../templates', __FILE__)
8
9
  end
9
10
 
10
- def create_swagger_layout
11
- template 'swagger.html.haml', File.join('app', 'views', 'layouts', 'swagger.html.haml')
11
+ def create_swagger_layout
12
+ template "swagger.html.#{template_engine.underscore}", File.join('app', 'views', 'layouts', "swagger.html.#{template_engine.underscore}")
12
13
  end
13
14
  end
14
15
  end
@@ -0,0 +1,106 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html lang="<%%= I18n.locale.to_s %>" xml:lang="<%%= I18n.locale.to_s %>" xmlns="http://www.w3.org/1999/xhtml">
3
+ <head>
4
+ <title>Swagger UI</title>
5
+ <%%= javascript_include_tag :swagger_ui %>
6
+ <%%= stylesheet_link_tag :swagger_ui_screen, :media => :screen %>
7
+ <%%= stylesheet_link_tag :swagger_ui_print, :media => :print %>
8
+ <%%= csrf_meta_tags %>
9
+ <style>
10
+ .swagger-ui-wrap {
11
+ max-width: 80%;
12
+ min-width: 960px;
13
+ margin-left: auto;
14
+ margin-right: auto;
15
+ }
16
+ </style>
17
+
18
+ <script>
19
+ $(function () {
20
+ var url = window.location.search.match(/url=([^&]+)/);
21
+ if (url && url.length > 1) {
22
+ url = decodeURIComponent(url[1]);
23
+ } else {
24
+ url = "<%%= request.protocol %><%%= request.host %>:<%%= request.port %>/api/v1/swagger_doc";
25
+ }
26
+
27
+ hljs.configure({
28
+ highlightSizeThreshold: 5000
29
+ });
30
+
31
+ // Pre load translate...
32
+ if(window.SwaggerTranslator) {
33
+ window.SwaggerTranslator.translate();
34
+ }
35
+ window.swaggerUi = new SwaggerUi({
36
+ url: url,
37
+ dom_id: "swagger-ui-container",
38
+ supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
39
+ onComplete: function(swaggerApi, swaggerUi){
40
+ if(typeof initOAuth == "function") {
41
+ initOAuth({
42
+ clientId: "your-client-id",
43
+ clientSecret: "your-client-secret-if-required",
44
+ realm: "your-realms",
45
+ appName: "your-app-name",
46
+ scopeSeparator: ",",
47
+ additionalQueryStringParams: {}
48
+ });
49
+ }
50
+
51
+ if(window.SwaggerTranslator) {
52
+ window.SwaggerTranslator.translate();
53
+ }
54
+ },
55
+ onFailure: function(data) {
56
+ log("Unable to Load SwaggerUI");
57
+ },
58
+ docExpansion: "none",
59
+ jsonEditor: false,
60
+ defaultModelRendering: 'schema',
61
+ showRequestHeaders: false
62
+ });
63
+
64
+ $('#input_apiKey').change(function() {
65
+ var key = $('#input_apiKey')[0].value;
66
+ if(key && key.trim() != "") {
67
+ swaggerUi.api.clientAuthorizations.add("key", new SwaggerClient.ApiKeyAuthorization("api_key", key, "query"));
68
+ }
69
+ })
70
+
71
+ window.swaggerUi.load();
72
+
73
+ function log() {
74
+ if ('console' in window) {
75
+ console.log.apply(console, arguments);
76
+ }
77
+ }
78
+ });
79
+
80
+
81
+ </script>
82
+ </head>
83
+ <body class="swagger-section">
84
+ <div id="header">
85
+ <div class="swagger-ui-wrap">
86
+ <a href="http://swagger.io" id="logo">
87
+ <span class="logo__title">swagger</span>
88
+ </a>
89
+ <form id="api_selector">
90
+ <div class="input">
91
+ <input id="input_baseUrl" name="baseUrl" placeholder="http://example.com/api" type="text">/</input>
92
+ </div>
93
+ <div class="input">
94
+ <input id="input_apiKey" name="apiKey" placeholder="api_key" type="text"></input>
95
+ </div>
96
+ <div id="auth_container"></div>
97
+ <div class="input">
98
+ <a class="header__btn" href="#" id="explore">Explore</a>
99
+ </div>
100
+ </form>
101
+ </div>
102
+ </div>
103
+ <div class="swagger-ui-wrap" id="message-bar">&nbsp;</div>
104
+ <div class="swagger-ui-wrap" id="swagger-ui-container"></div>
105
+ </body>
106
+ </html>
@@ -22,7 +22,7 @@
22
22
  if (url && url.length > 1) {
23
23
  url = decodeURIComponent(url[1]);
24
24
  } else {
25
- url = "http://#{request.host}:#{request.port}/api/v1/swagger_doc";
25
+ url = "#{request.protocol}#{request.host}:#{request.port}/api/v1/swagger_doc";
26
26
  }
27
27
 
28
28
  hljs.configure({
@@ -93,4 +93,3 @@
93
93
  %a#explore.header__btn{"data-sw-translate" => "", :href => "#"} Explore
94
94
  #message-bar.swagger-ui-wrap{"data-sw-translate" => ""} &nbsp;
95
95
  #swagger-ui-container.swagger-ui-wrap
96
-
@@ -0,0 +1,96 @@
1
+ doctype html
2
+ html xmlns="http://www.w3.org/1999/xhtml" lang=I18n.locale.to_s xml:lang=(I18n.locale.to_s )
3
+ head
4
+ title Swagger UI
5
+
6
+ = javascript_include_tag :swagger_ui
7
+ = stylesheet_link_tag :swagger_ui_screen, :media => :screen
8
+ = stylesheet_link_tag :swagger_ui_print, :media => :print
9
+ = csrf_meta_tags
10
+
11
+ css:
12
+ .swagger-ui-wrap {
13
+ max-width: 80%;
14
+ min-width: 960px;
15
+ margin-left: auto;
16
+ margin-right: auto;
17
+ }
18
+
19
+ javascript:
20
+ $(function () {
21
+ var url = window.location.search.match(/url=([^&]+)/);
22
+ if (url && url.length > 1) {
23
+ url = decodeURIComponent(url[1]);
24
+ } else {
25
+ url = "#{request.protocol}#{request.host}:#{request.port}/api/v1/swagger_doc";
26
+ }
27
+
28
+ hljs.configure({
29
+ highlightSizeThreshold: 5000
30
+ });
31
+
32
+ // Pre load translate...
33
+ if(window.SwaggerTranslator) {
34
+ window.SwaggerTranslator.translate();
35
+ }
36
+ window.swaggerUi = new SwaggerUi({
37
+ url: url,
38
+ dom_id: "swagger-ui-container",
39
+ supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
40
+ onComplete: function(swaggerApi, swaggerUi){
41
+ if(typeof initOAuth == "function") {
42
+ initOAuth({
43
+ clientId: "your-client-id",
44
+ clientSecret: "your-client-secret-if-required",
45
+ realm: "your-realms",
46
+ appName: "your-app-name",
47
+ scopeSeparator: ",",
48
+ additionalQueryStringParams: {}
49
+ });
50
+ }
51
+
52
+ if(window.SwaggerTranslator) {
53
+ window.SwaggerTranslator.translate();
54
+ }
55
+ },
56
+ onFailure: function(data) {
57
+ log("Unable to Load SwaggerUI");
58
+ },
59
+ docExpansion: "none",
60
+ jsonEditor: false,
61
+ defaultModelRendering: 'schema',
62
+ showRequestHeaders: false
63
+ });
64
+
65
+ $('#input_apiKey').change(function() {
66
+ var key = $('#input_apiKey')[0].value;
67
+ if(key && key.trim() != "") {
68
+ swaggerUi.api.clientAuthorizations.add("key", new SwaggerClient.ApiKeyAuthorization("api_key", key, "query"));
69
+ }
70
+ })
71
+
72
+ window.swaggerUi.load();
73
+
74
+ function log() {
75
+ if ('console' in window) {
76
+ console.log.apply(console, arguments);
77
+ }
78
+ }
79
+ });
80
+
81
+ body.swagger-section
82
+ #header
83
+ .swagger-ui-wrap
84
+ a#logo href="http://swagger.io"
85
+ span.logo__title swagger
86
+ form#api_selector
87
+ .input
88
+ input#input_baseUrl name="baseUrl" placeholder="http://example.com/api" type="text" /
89
+ .input
90
+ input#input_apiKey name="apiKey" placeholder="api_key" type="text"
91
+ #auth_container
92
+ .input
93
+ a#explore.header__btn data-sw-translate="" href="#" Explore
94
+
95
+ #message-bar.swagger-ui-wrap data-sw-translate="" &nbsp;
96
+ #swagger-ui-container.swagger-ui-wrap
@@ -1,7 +1,7 @@
1
1
  module Grape
2
2
  module Swagger
3
3
  module Ui
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape-swagger-ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Klaas Endrikat
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-09 00:00:00.000000000 Z
11
+ date: 2017-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -44,7 +44,9 @@ files:
44
44
  - grape-swagger-ui.gemspec
45
45
  - lib/generators/swagger/layout/USAGE
46
46
  - lib/generators/swagger/layout/layout_generator.rb
47
+ - lib/generators/swagger/layout/templates/swagger.html.erb
47
48
  - lib/generators/swagger/layout/templates/swagger.html.haml
49
+ - lib/generators/swagger/layout/templates/swagger.html.slim
48
50
  - lib/grape-swagger-ui.rb
49
51
  - lib/grape-swagger-ui/version.rb
50
52
  - vendor/assets/fonts/DroidSans-Bold.ttf
@@ -117,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
119
  version: '0'
118
120
  requirements: []
119
121
  rubyforge_project:
120
- rubygems_version: 2.2.2
122
+ rubygems_version: 2.5.2
121
123
  signing_key:
122
124
  specification_version: 4
123
125
  summary: swagger ui js integration for grape and grape-swagger