easy_swagger_ui 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +7 -0
  3. data/MIT-LICENSE +20 -0
  4. data/README.md +76 -0
  5. data/Rakefile +18 -0
  6. data/app/assets/config/easy_swagger_ui_manifest.js +5 -0
  7. data/app/assets/fonts/easy_swagger_ui/DroidSans-Bold.ttf +0 -0
  8. data/app/assets/fonts/easy_swagger_ui/DroidSans.ttf +0 -0
  9. data/app/assets/images/easy_swagger_ui/collapse.gif +0 -0
  10. data/app/assets/images/easy_swagger_ui/expand.gif +0 -0
  11. data/app/assets/images/easy_swagger_ui/explorer_icons.png +0 -0
  12. data/app/assets/images/easy_swagger_ui/favicon-16x16.png +0 -0
  13. data/app/assets/images/easy_swagger_ui/favicon-32x32.png +0 -0
  14. data/app/assets/images/easy_swagger_ui/logo_small.png +0 -0
  15. data/app/assets/images/easy_swagger_ui/pet_store_api.png +0 -0
  16. data/app/assets/images/easy_swagger_ui/throbber.gif +0 -0
  17. data/app/assets/images/easy_swagger_ui/wordnik_api.png +0 -0
  18. data/app/assets/javascripts/easy_swagger_ui/application.js +14 -0
  19. data/app/assets/javascripts/easy_swagger_ui/lang/ca.js +53 -0
  20. data/app/assets/javascripts/easy_swagger_ui/lang/el.js +56 -0
  21. data/app/assets/javascripts/easy_swagger_ui/lang/en.js +56 -0
  22. data/app/assets/javascripts/easy_swagger_ui/lang/es.js +53 -0
  23. data/app/assets/javascripts/easy_swagger_ui/lang/fr.js +54 -0
  24. data/app/assets/javascripts/easy_swagger_ui/lang/geo.js +56 -0
  25. data/app/assets/javascripts/easy_swagger_ui/lang/it.js +52 -0
  26. data/app/assets/javascripts/easy_swagger_ui/lang/ja.js +56 -0
  27. data/app/assets/javascripts/easy_swagger_ui/lang/ko-kr.js +53 -0
  28. data/app/assets/javascripts/easy_swagger_ui/lang/pl.js +53 -0
  29. data/app/assets/javascripts/easy_swagger_ui/lang/pt.js +53 -0
  30. data/app/assets/javascripts/easy_swagger_ui/lang/ru.js +56 -0
  31. data/app/assets/javascripts/easy_swagger_ui/lang/tr.js +53 -0
  32. data/app/assets/javascripts/easy_swagger_ui/lang/translator.js +39 -0
  33. data/app/assets/javascripts/easy_swagger_ui/lang/zh-cn.js +56 -0
  34. data/app/assets/javascripts/easy_swagger_ui/lib/backbone-min.js +1 -0
  35. data/app/assets/javascripts/easy_swagger_ui/lib/handlebars-4.0.5.js +3 -0
  36. data/app/assets/javascripts/easy_swagger_ui/lib/highlight.9.1.0.pack.js +1 -0
  37. data/app/assets/javascripts/easy_swagger_ui/lib/highlight.9.1.0.pack_extended.js +1 -0
  38. data/app/assets/javascripts/easy_swagger_ui/lib/jquery-1.8.0.min.js +3 -0
  39. data/app/assets/javascripts/easy_swagger_ui/lib/jquery.ba-bbq.min.js +1 -0
  40. data/app/assets/javascripts/easy_swagger_ui/lib/jquery.slideto.min.js +1 -0
  41. data/app/assets/javascripts/easy_swagger_ui/lib/jquery.wiggle.min.js +1 -0
  42. data/app/assets/javascripts/easy_swagger_ui/lib/js-yaml.min.js +2 -0
  43. data/app/assets/javascripts/easy_swagger_ui/lib/jsoneditor.min.js +5 -0
  44. data/app/assets/javascripts/easy_swagger_ui/lib/lodash.min.js +2 -0
  45. data/app/assets/javascripts/easy_swagger_ui/lib/marked.js +1 -0
  46. data/app/assets/javascripts/easy_swagger_ui/lib/object-assign-pollyfill.js +1 -0
  47. data/app/assets/javascripts/easy_swagger_ui/lib/swagger-oauth.js +1 -0
  48. data/app/assets/javascripts/easy_swagger_ui/swagger-ui.js +25344 -0
  49. data/app/assets/stylesheets/easy_swagger_ui/application.css +5 -0
  50. data/app/assets/stylesheets/easy_swagger_ui/lib/print.css.erb +1377 -0
  51. data/app/assets/stylesheets/easy_swagger_ui/lib/reset.css +125 -0
  52. data/app/assets/stylesheets/easy_swagger_ui/lib/screen.css.erb +1504 -0
  53. data/app/assets/stylesheets/easy_swagger_ui/lib/style.css +248 -0
  54. data/app/assets/stylesheets/easy_swagger_ui/lib/typography.css.erb +14 -0
  55. data/app/assets/stylesheets/easy_swagger_ui/print.css +4 -0
  56. data/app/controllers/easy_swagger_ui/application_controller.rb +6 -0
  57. data/app/controllers/easy_swagger_ui/swagger_controller.rb +62 -0
  58. data/app/helpers/easy_swagger_ui/application_helper.rb +7 -0
  59. data/app/views/easy_swagger_ui/swagger/oauth2.html.erb +20 -0
  60. data/app/views/easy_swagger_ui/swagger/view.html.erb +99 -0
  61. data/config/initializers/assets.rb +7 -0
  62. data/config/initializers/easy_swagger_ui.rb +7 -0
  63. data/config/routes.rb +8 -0
  64. data/lib/easy_swagger_ui.rb +19 -0
  65. data/lib/easy_swagger_ui/configuration.rb +34 -0
  66. data/lib/easy_swagger_ui/engine.rb +5 -0
  67. data/lib/easy_swagger_ui/route_matcher.rb +13 -0
  68. data/lib/easy_swagger_ui/version.rb +4 -0
  69. metadata +184 -0
@@ -0,0 +1,248 @@
1
+ .swagger-section #header a#logo {
2
+ font-size: 1.5em;
3
+ font-weight: bold;
4
+ text-decoration: none;
5
+ padding: 20px 0 20px 40px;
6
+ }
7
+ #text-head {
8
+ font-size: 80px;
9
+ font-family: 'Roboto', sans-serif;
10
+ color: #ffffff;
11
+ float: right;
12
+ margin-right: 20%;
13
+ }
14
+ .navbar-fixed-top .navbar-nav {
15
+ height: auto;
16
+ }
17
+ .navbar-fixed-top .navbar-brand {
18
+ height: auto;
19
+ }
20
+ .navbar-header {
21
+ height: auto;
22
+ }
23
+ .navbar-inverse {
24
+ background-color: #000;
25
+ border-color: #000;
26
+ }
27
+ #navbar-brand {
28
+ margin-left: 20%;
29
+ }
30
+ .navtext {
31
+ font-size: 10px;
32
+ }
33
+ .h1,
34
+ h1 {
35
+ font-size: 60px;
36
+ }
37
+ .navbar-default .navbar-header .navbar-brand {
38
+ color: #a2dfee;
39
+ }
40
+ /* tag titles */
41
+ .swagger-section .swagger-ui-wrap ul#resources li.resource div.heading h2 a {
42
+ color: #393939;
43
+ font-family: 'Arvo', serif;
44
+ font-size: 1.5em;
45
+ }
46
+ .swagger-section .swagger-ui-wrap ul#resources li.resource div.heading h2 a:hover {
47
+ color: black;
48
+ }
49
+ .swagger-section .swagger-ui-wrap ul#resources li.resource div.heading h2 {
50
+ color: #525252;
51
+ padding-left: 0px;
52
+ display: block;
53
+ clear: none;
54
+ float: left;
55
+ font-family: 'Arvo', serif;
56
+ font-weight: bold;
57
+ }
58
+ .navbar-default .navbar-collapse,
59
+ .navbar-default .navbar-form {
60
+ border-color: #0A0A0A;
61
+ }
62
+ .container1 {
63
+ width: 1500px;
64
+ margin: auto;
65
+ margin-top: 0;
66
+ background-repeat: no-repeat;
67
+ background-position: -40px -20px;
68
+ margin-bottom: 210px;
69
+ }
70
+ .container-inner {
71
+ width: 1200px;
72
+ margin: auto;
73
+ background-color: rgba(223, 227, 228, 0.75);
74
+ padding-bottom: 40px;
75
+ padding-top: 40px;
76
+ border-radius: 15px;
77
+ }
78
+ .header-content {
79
+ padding: 0;
80
+ width: 1000px;
81
+ }
82
+ .title1 {
83
+ font-size: 80px;
84
+ font-family: 'Vollkorn', serif;
85
+ color: #404040;
86
+ text-align: center;
87
+ padding-top: 40px;
88
+ padding-bottom: 100px;
89
+ }
90
+ #icon {
91
+ margin-top: -18px;
92
+ }
93
+ .subtext {
94
+ font-size: 25px;
95
+ font-style: italic;
96
+ color: #08b;
97
+ text-align: right;
98
+ padding-right: 250px;
99
+ }
100
+ .bg-primary {
101
+ background-color: #00468b;
102
+ }
103
+ .navbar-default .nav > li > a,
104
+ .navbar-default .nav > li > a:focus {
105
+ color: #08b;
106
+ }
107
+ .navbar-default .nav > li > a,
108
+ .navbar-default .nav > li > a:hover {
109
+ color: #08b;
110
+ }
111
+ .navbar-default .nav > li > a,
112
+ .navbar-default .nav > li > a:focus:hover {
113
+ color: #08b;
114
+ }
115
+ .text-faded {
116
+ font-size: 25px;
117
+ font-family: 'Vollkorn', serif;
118
+ }
119
+ .section-heading {
120
+ font-family: 'Vollkorn', serif;
121
+ font-size: 45px;
122
+ padding-bottom: 10px;
123
+ }
124
+ hr {
125
+ border-color: #00468b;
126
+ padding-bottom: 10px;
127
+ }
128
+ .description {
129
+ margin-top: 20px;
130
+ padding-bottom: 200px;
131
+ }
132
+ .description li {
133
+ font-family: 'Vollkorn', serif;
134
+ font-size: 25px;
135
+ color: #525252;
136
+ margin-left: 28%;
137
+ padding-top: 5px;
138
+ }
139
+ .gap {
140
+ margin-top: 200px;
141
+ }
142
+ .troubleshootingtext {
143
+ color: rgba(255, 255, 255, 0.7);
144
+ padding-left: 30%;
145
+ }
146
+ .troubleshootingtext li {
147
+ list-style-type: circle;
148
+ font-size: 25px;
149
+ padding-bottom: 5px;
150
+ }
151
+ .overlay {
152
+ position: absolute;
153
+ top: 0;
154
+ left: 0;
155
+ width: 100%;
156
+ height: 100%;
157
+ z-index: 1000;
158
+ }
159
+ .block.response_body.json:hover {
160
+ cursor: pointer;
161
+ }
162
+ .backdrop {
163
+ color: blue;
164
+ }
165
+ #myModal {
166
+ height: 100%;
167
+ }
168
+ .modal-backdrop {
169
+ bottom: 0;
170
+ position: fixed;
171
+ }
172
+ .curl {
173
+ padding: 10px;
174
+ font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace;
175
+ font-size: 0.9em;
176
+ max-height: 400px;
177
+ margin-top: 5px;
178
+ overflow-y: auto;
179
+ background-color: #fcf6db;
180
+ border: 1px solid #e5e0c6;
181
+ border-radius: 4px;
182
+ }
183
+ .curl_title {
184
+ font-size: 1.1em;
185
+ margin: 0;
186
+ padding: 15px 0 5px;
187
+ font-family: 'Open Sans', 'Helvetica Neue', Arial, sans-serif;
188
+ font-weight: 500;
189
+ line-height: 1.1;
190
+ }
191
+ .footer {
192
+ display: none;
193
+ }
194
+ .swagger-section .swagger-ui-wrap h2 {
195
+ padding: 0;
196
+ }
197
+ h2 {
198
+ margin: 0;
199
+ margin-bottom: 5px;
200
+ }
201
+ .markdown p {
202
+ font-size: 15px;
203
+ font-family: 'Arvo', serif;
204
+ }
205
+ .swagger-section .swagger-ui-wrap .code {
206
+ font-size: 15px;
207
+ font-family: 'Arvo', serif;
208
+ }
209
+ .swagger-section .swagger-ui-wrap b {
210
+ font-family: 'Arvo', serif;
211
+ }
212
+ #signin:hover {
213
+ cursor: pointer;
214
+ }
215
+ .dropdown-menu {
216
+ padding: 15px;
217
+ }
218
+ .navbar-right .dropdown-menu {
219
+ left: 0;
220
+ right: auto;
221
+ }
222
+ #signinbutton {
223
+ width: 100%;
224
+ height: 32px;
225
+ font-size: 13px;
226
+ font-weight: bold;
227
+ color: #08b;
228
+ }
229
+ .navbar-default .nav > li .details {
230
+ color: #000000;
231
+ text-transform: none;
232
+ font-size: 15px;
233
+ font-weight: normal;
234
+ font-family: 'Open Sans', sans-serif;
235
+ font-style: italic;
236
+ line-height: 20px;
237
+ top: -2px;
238
+ }
239
+ .navbar-default .nav > li .details:hover {
240
+ color: black;
241
+ }
242
+ #signout {
243
+ width: 100%;
244
+ height: 32px;
245
+ font-size: 13px;
246
+ font-weight: bold;
247
+ color: #08b;
248
+ }
@@ -0,0 +1,14 @@
1
+ /* Google Font's Droid Sans */
2
+ @font-face {
3
+ font-family: 'Droid Sans';
4
+ font-style: normal;
5
+ font-weight: 400;
6
+ src: local('Droid Sans'), local('DroidSans'), url("<%= asset_path('easy_swagger_ui/DroidSans.ttf') %>") format('truetype');
7
+ }
8
+ /* Google Font's Droid Sans Bold */
9
+ @font-face {
10
+ font-family: 'Droid Sans';
11
+ font-style: normal;
12
+ font-weight: 700;
13
+ src: local('Droid Sans Bold'), local('DroidSans-Bold'), url("<%= asset_path('easy_swagger_ui/DroidSans-Bold.ttf') %>") format('truetype');
14
+ }
@@ -0,0 +1,4 @@
1
+ /*
2
+ *= require ./lib/reset.css
3
+ *= require ./lib/print.css
4
+ */
@@ -0,0 +1,6 @@
1
+ module EasySwaggerUi
2
+ class ApplicationController < ActionController::Base
3
+ protect_from_forgery with: :exception
4
+ layout false
5
+ end
6
+ end
@@ -0,0 +1,62 @@
1
+ module EasySwaggerUi
2
+ class SwaggerController < ApplicationController
3
+ # get 'oauth2'
4
+ def oauth2
5
+ end
6
+
7
+ # get '*doc_path'
8
+ def view
9
+ end
10
+
11
+ # get '*doc_path.json'
12
+ def spec
13
+ if EasySwaggerUi.cache_enabled
14
+ cache_key = "easy_swagger_ui:spec:#{params[:doc_path]}"
15
+ options = {
16
+ expires_in: EasySwaggerUi.cache_timeout,
17
+ race_condition_ttl: 10,
18
+ }
19
+ spec = EasySwaggerUi.cache_store.fetch(cache_key, options) do
20
+ parse_spec(params[:doc_path])
21
+ end
22
+ else
23
+ spec = parse_spec(params[:doc_path])
24
+ end
25
+ render json: spec
26
+ end
27
+
28
+ protected
29
+
30
+ def parse_file(filepath)
31
+ erb = ERB.new(File.read(filepath), nil, '-')
32
+ erb.location = filepath
33
+ YAML.safe_load(erb.result) || {}
34
+ end
35
+
36
+ def parse_spec(path)
37
+ doc_path = File.join(EasySwaggerUi.base_path, path)
38
+ return {} if Dir["#{doc_path}/*.yml"].blank?
39
+
40
+ spec = parse_file(File.join(doc_path, 'swagger.yml'))
41
+
42
+ Dir["#{doc_path}/*.yml"].sort.each do |filepath|
43
+ filename = File.basename(filepath, '.yml')
44
+ next if filename == 'swagger'
45
+ spec.merge!(filename => parse_file(filepath))
46
+ end
47
+
48
+ Dir["#{doc_path}/*"].sort.each do |dirpath|
49
+ next unless File.directory?(dirpath)
50
+ dir_name = File.basename(dirpath)
51
+ results = Dir["#{dirpath}/*.yml"].sort.map do |filepath2|
52
+ parse_file(filepath2)
53
+ end
54
+ spec.merge!(dir_name => results.reduce(&:merge!) || {})
55
+ end
56
+
57
+ spec['host'] = request.host_with_port unless spec.key?('host')
58
+
59
+ spec
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,7 @@
1
+ module EasySwaggerUi
2
+ module ApplicationHelper
3
+ def swagger_routes
4
+ Engine.routes.url_helpers
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,20 @@
1
+ <script>
2
+ var qp = null;
3
+ if(/code|token|error/.test(window.location.hash)) {
4
+ qp = location.hash.substring(1);
5
+ }
6
+ else {
7
+ qp = location.search.substring(1);
8
+ }
9
+ qp = qp ? JSON.parse('{"' + qp.replace(/&/g, '","').replace(/=/g,'":"') + '"}',
10
+ function(key, value) {
11
+ return key===""?value:decodeURIComponent(value) }
12
+ ):{}
13
+
14
+ if (window.opener.swaggerUiAuth.tokenUrl)
15
+ window.opener.processOAuthCode(qp);
16
+ else
17
+ window.opener.onOAuthComplete(qp);
18
+
19
+ window.close();
20
+ </script>
@@ -0,0 +1,99 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta http-equiv="x-ua-compatible" content="IE=edge">
6
+ <title>Swagger UI</title>
7
+ <link rel="icon" type="image/png" href="<%= image_path('easy_swagger_ui/favicon-32x32.png') %>" sizes="32x32" />
8
+ <link rel="icon" type="image/png" href="<%= image_path('easy_swagger_ui/favicon-16x16.png') %>" sizes="16x16" />
9
+
10
+ <%= stylesheet_link_tag "easy_swagger_ui/application", media: "screen" %>
11
+ <%= stylesheet_link_tag "easy_swagger_ui/print", media: "print" %>
12
+
13
+ <%= javascript_include_tag "easy_swagger_ui/application" %>
14
+
15
+ <%
16
+ asset_name = "easy_swagger_ui/lang/#{I18n.locale.to_s.downcase}.js"
17
+ translation = Rails.application.assets.find_asset(asset_name)
18
+ %>
19
+ <% if translation %>
20
+ <%= javascript_include_tag "easy_swagger_ui/lang/translator" %>
21
+ <%= javascript_include_tag asset_name %>
22
+ <% end %>
23
+
24
+ <script type="text/javascript">
25
+ $(function () {
26
+ var url = window.location.search.match(/url=([^&]+)/);
27
+ if (url && url.length > 1) {
28
+ url = decodeURIComponent(url[1]);
29
+ } else {
30
+ url = "<%= request.path %>.json";
31
+ }
32
+
33
+ hljs.configure({
34
+ highlightSizeThreshold: 5000
35
+ });
36
+
37
+ // Pre load translate...
38
+ if(window.SwaggerTranslator) {
39
+ window.SwaggerTranslator.translate();
40
+ }
41
+ window.swaggerUi = new SwaggerUi({
42
+ url: url,
43
+ validatorUrl: <%=raw EasySwaggerUi.validator_enabled ? "'//online.swagger.io/validator'" : 'null' %>,
44
+ oauth2RedirectUrl: "<%= swagger_routes.oauth2_path %>",
45
+ dom_id: "swagger-ui-container",
46
+ supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
47
+ onComplete: function(swaggerApi, swaggerUi){
48
+ if(typeof initOAuth == "function") {
49
+ initOAuth({
50
+ clientId: "your-client-id",
51
+ clientSecret: "your-client-secret-if-required",
52
+ realm: "your-realms",
53
+ appName: "your-app-name",
54
+ scopeSeparator: " ",
55
+ additionalQueryStringParams: {}
56
+ });
57
+ }
58
+
59
+ if(window.SwaggerTranslator) {
60
+ window.SwaggerTranslator.translate();
61
+ }
62
+ },
63
+ onFailure: function(data) {
64
+ log("Unable to Load SwaggerUI");
65
+ },
66
+ docExpansion: "none",
67
+ jsonEditor: false,
68
+ defaultModelRendering: 'schema',
69
+ showRequestHeaders: false,
70
+ showOperationIds: false
71
+ });
72
+
73
+ window.swaggerUi.load();
74
+
75
+ function log() {
76
+ if ('console' in window) {
77
+ console.log.apply(console, arguments);
78
+ }
79
+ }
80
+ });
81
+ </script>
82
+ </head>
83
+
84
+ <body class="swagger-section">
85
+ <div id='header'>
86
+ <div class="swagger-ui-wrap">
87
+ <a id="logo" href="http://swagger.io"><img class="logo__img" alt="swagger" height="30" width="30" src="<%= image_path('easy_swagger_ui/logo_small.png') %>" /><span class="logo__title">swagger</span></a>
88
+ <form id='api_selector'>
89
+ <div class='input'><input placeholder="http://example.com/api" id="input_baseUrl" name="baseUrl" type="text"/></div>
90
+ <div id='auth_container'></div>
91
+ <div class='input'><a id="explore" class="header__btn" href="#" data-sw-translate>Explore</a></div>
92
+ </form>
93
+ </div>
94
+ </div>
95
+
96
+ <div id="message-bar" class="swagger-ui-wrap" data-sw-translate>&nbsp;</div>
97
+ <div id="swagger-ui-container" class="swagger-ui-wrap"></div>
98
+ </body>
99
+ </html>