grape-swagger-rails 0.1.0 → 0.2.0

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.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +5 -0
  3. data/.rubocop_todo.yml +61 -0
  4. data/.travis.yml +5 -2
  5. data/CHANGELOG.md +11 -0
  6. data/CONTRIBUTING.md +13 -10
  7. data/Gemfile +6 -0
  8. data/README.md +58 -2
  9. data/RELEASING.md +1 -1
  10. data/Rakefile +6 -6
  11. data/app/assets/images/grape_swagger_rails/favicon-16x16.png +0 -0
  12. data/app/assets/images/grape_swagger_rails/favicon-32x32.png +0 -0
  13. data/app/assets/images/grape_swagger_rails/favicon.ico +0 -0
  14. data/app/assets/javascripts/grape_swagger_rails/application.js +2 -3
  15. data/app/assets/javascripts/grape_swagger_rails/backbone-min.js +14 -37
  16. data/app/assets/javascripts/grape_swagger_rails/handlebars-2.0.0.js +28 -0
  17. data/app/assets/javascripts/grape_swagger_rails/jquery-1.8.0.min.js +1 -1
  18. data/app/assets/javascripts/grape_swagger_rails/marked.js +1272 -0
  19. data/app/assets/javascripts/grape_swagger_rails/swagger-oauth.js +133 -54
  20. data/app/assets/javascripts/grape_swagger_rails/swagger-ui.min.js +13 -1
  21. data/app/assets/javascripts/grape_swagger_rails/underscore-min.js +6 -32
  22. data/app/assets/javascripts/grape_swagger_rails/underscore-min.map +1 -0
  23. data/app/assets/stylesheets/grape_swagger_rails/print.css +1172 -0
  24. data/app/assets/stylesheets/grape_swagger_rails/screen.css.erb +68 -13
  25. data/app/assets/stylesheets/grape_swagger_rails/style.css +250 -0
  26. data/app/assets/stylesheets/grape_swagger_rails/typography.css +26 -0
  27. data/app/views/grape_swagger_rails/application/index.html.erb +15 -10
  28. data/config/routes.rb +1 -1
  29. data/grape-swagger-rails.gemspec +7 -3
  30. data/lib/grape-swagger-rails.rb +4 -3
  31. data/lib/grape-swagger-rails/version.rb +1 -1
  32. data/lib/tasks/swagger_ui.rake +43 -44
  33. data/spec/dummy/bin/rails +2 -2
  34. data/spec/dummy/bin/rake +1 -1
  35. data/spec/dummy/bin/spring +6 -6
  36. data/spec/dummy/config.ru +1 -1
  37. data/spec/dummy/config/application.rb +2 -1
  38. data/spec/dummy/config/environments/development.rb +3 -0
  39. data/spec/dummy/config/environments/production.rb +1 -1
  40. data/spec/dummy/config/environments/test.rb +4 -1
  41. data/spec/features/grape-swagger-rails_spec.rb +1 -1
  42. data/spec/features/swagger_spec.rb +71 -27
  43. data/spec/spec_helper.rb +1 -1
  44. metadata +108 -45
  45. data/app/assets/javascripts/grape_swagger_rails/handlebars-1.0.0.js +0 -2278
  46. data/app/assets/javascripts/grape_swagger_rails/shred.bundle.js +0 -2765
  47. data/app/assets/javascripts/grape_swagger_rails/shred/content.js +0 -193
  48. data/app/assets/javascripts/grape_swagger_rails/swagger.js +0 -1603
@@ -274,6 +274,9 @@
274
274
  font-weight: bold;
275
275
  font-size: 25px;
276
276
  }
277
+ .swagger-section .swagger-ui-wrap .footer {
278
+ margin-top: 20px;
279
+ }
277
280
  .swagger-section .swagger-ui-wrap p.big,
278
281
  .swagger-section .swagger-ui-wrap div.big p {
279
282
  font-size: 1em;
@@ -294,7 +297,13 @@
294
297
  .swagger-section .swagger-ui-wrap .message-fail {
295
298
  color: #cc0000;
296
299
  }
297
- .swagger-section .swagger-ui-wrap .info_contact {
300
+ .swagger-section .swagger-ui-wrap .info_url {
301
+ padding-bottom: 5px;
302
+ }
303
+ .swagger-section .swagger-ui-wrap .info_email {
304
+ padding-bottom: 5px;
305
+ }
306
+ .swagger-section .swagger-ui-wrap .info_name {
298
307
  padding-bottom: 5px;
299
308
  }
300
309
  .swagger-section .swagger-ui-wrap .info_description {
@@ -391,6 +400,43 @@
391
400
  font-weight: bold;
392
401
  color: #000;
393
402
  }
403
+ .swagger-section .swagger-ui-wrap .model-signature .description .propWrap .optionsWrapper {
404
+ border-spacing: 0;
405
+ position: absolute;
406
+ background-color: #ffffff;
407
+ border: 1px solid #bbbbbb;
408
+ display: none;
409
+ font-size: 11px;
410
+ max-width: 400px;
411
+ line-height: 30px;
412
+ color: black;
413
+ padding: 5px;
414
+ margin-left: 10px;
415
+ }
416
+ .swagger-section .swagger-ui-wrap .model-signature .description .propWrap .optionsWrapper th {
417
+ text-align: center;
418
+ background-color: #eeeeee;
419
+ border: 1px solid #bbbbbb;
420
+ font-size: 11px;
421
+ color: #666666;
422
+ font-weight: bold;
423
+ padding: 5px;
424
+ line-height: 15px;
425
+ }
426
+ .swagger-section .swagger-ui-wrap .model-signature .description .propWrap .optionsWrapper .optionName {
427
+ font-weight: bold;
428
+ }
429
+ .swagger-section .swagger-ui-wrap .model-signature .description .propDesc.markdown > p:first-child,
430
+ .swagger-section .swagger-ui-wrap .model-signature .description .propDesc.markdown > p:last-child {
431
+ display: inline;
432
+ }
433
+ .swagger-section .swagger-ui-wrap .model-signature .description .propDesc.markdown > p:not(:first-child):before {
434
+ display: block;
435
+ content: '';
436
+ }
437
+ .swagger-section .swagger-ui-wrap .model-signature .description span:last-of-type.propDesc.markdown > p:only-child {
438
+ margin-right: -3px;
439
+ }
394
440
  .swagger-section .swagger-ui-wrap .model-signature .propName {
395
441
  font-weight: bold;
396
442
  }
@@ -1034,6 +1080,9 @@
1034
1080
  .swagger-section .swagger-ui-wrap form.form_box p strong {
1035
1081
  color: black;
1036
1082
  }
1083
+ .swagger-section .swagger-ui-wrap .operation-status td.markdown > p:last-child {
1084
+ padding-bottom: 0;
1085
+ }
1037
1086
  .swagger-section .title {
1038
1087
  font-style: bold;
1039
1088
  }
@@ -1106,8 +1155,16 @@
1106
1155
  .swagger-section .auth {
1107
1156
  float: right;
1108
1157
  }
1109
- .swagger-section #api_information_panel {
1110
- position: absolute;
1158
+ .swagger-section .api-ic {
1159
+ height: 18px;
1160
+ vertical-align: middle;
1161
+ display: inline-block;
1162
+ background: url(<%= image_path('grape_swagger_rails/explorer_icons.png') %>) no-repeat;
1163
+ }
1164
+ .swagger-section .api-ic .api_information_panel {
1165
+ position: relative;
1166
+ margin-top: 20px;
1167
+ margin-left: -5px;
1111
1168
  background: #FFF;
1112
1169
  border: 1px solid #ccc;
1113
1170
  border-radius: 5px;
@@ -1118,34 +1175,32 @@
1118
1175
  color: black;
1119
1176
  padding: 5px;
1120
1177
  }
1121
- .swagger-section #api_information_panel p .api-msg-enabled {
1178
+ .swagger-section .api-ic .api_information_panel p .api-msg-enabled {
1122
1179
  color: green;
1123
1180
  }
1124
- .swagger-section #api_information_panel p .api-msg-disabled {
1181
+ .swagger-section .api-ic .api_information_panel p .api-msg-disabled {
1125
1182
  color: red;
1126
1183
  }
1127
- .swagger-section .api-ic {
1128
- height: 18px;
1129
- vertical-align: middle;
1130
- display: inline-block;
1131
- background: url(<%= image_path('grape_swagger_rails/explorer_icons.png') %>) no-repeat;
1184
+ .swagger-section .api-ic:hover .api_information_panel {
1185
+ position: absolute;
1186
+ display: block;
1132
1187
  }
1133
1188
  .swagger-section .ic-info {
1134
1189
  background-position: 0 0;
1135
1190
  width: 18px;
1136
- margin-top: -7px;
1191
+ margin-top: -6px;
1137
1192
  margin-left: 4px;
1138
1193
  }
1139
1194
  .swagger-section .ic-warning {
1140
1195
  background-position: -60px 0;
1141
1196
  width: 18px;
1142
- margin-top: -7px;
1197
+ margin-top: -6px;
1143
1198
  margin-left: 4px;
1144
1199
  }
1145
1200
  .swagger-section .ic-error {
1146
1201
  background-position: -30px 0;
1147
1202
  width: 18px;
1148
- margin-top: -7px;
1203
+ margin-top: -6px;
1149
1204
  margin-left: 4px;
1150
1205
  }
1151
1206
  .swagger-section .ic-off {
@@ -0,0 +1,250 @@
1
+ .swagger-section #header a#logo {
2
+ font-size: 1.5em;
3
+ font-weight: bold;
4
+ text-decoration: none;
5
+ background: transparent url(../images/logo.png) no-repeat left center;
6
+ padding: 20px 0 20px 40px;
7
+ }
8
+ #text-head {
9
+ font-size: 80px;
10
+ font-family: 'Roboto', sans-serif;
11
+ color: #ffffff;
12
+ float: right;
13
+ margin-right: 20%;
14
+ }
15
+ .navbar-fixed-top .navbar-nav {
16
+ height: auto;
17
+ }
18
+ .navbar-fixed-top .navbar-brand {
19
+ height: auto;
20
+ }
21
+ .navbar-header {
22
+ height: auto;
23
+ }
24
+ .navbar-inverse {
25
+ background-color: #000;
26
+ border-color: #000;
27
+ }
28
+ #navbar-brand {
29
+ margin-left: 20%;
30
+ }
31
+ .navtext {
32
+ font-size: 10px;
33
+ }
34
+ .h1,
35
+ h1 {
36
+ font-size: 60px;
37
+ }
38
+ .navbar-default .navbar-header .navbar-brand {
39
+ color: #a2dfee;
40
+ }
41
+ /* tag titles */
42
+ .swagger-section .swagger-ui-wrap ul#resources li.resource div.heading h2 a {
43
+ color: #393939;
44
+ font-family: 'Arvo', serif;
45
+ font-size: 1.5em;
46
+ }
47
+ .swagger-section .swagger-ui-wrap ul#resources li.resource div.heading h2 a:hover {
48
+ color: black;
49
+ }
50
+ .swagger-section .swagger-ui-wrap ul#resources li.resource div.heading h2 {
51
+ color: #525252;
52
+ padding-left: 0px;
53
+ display: block;
54
+ clear: none;
55
+ float: left;
56
+ font-family: 'Arvo', serif;
57
+ font-weight: bold;
58
+ }
59
+ .navbar-default .navbar-collapse,
60
+ .navbar-default .navbar-form {
61
+ border-color: #0A0A0A;
62
+ }
63
+ .container1 {
64
+ width: 1500px;
65
+ margin: auto;
66
+ margin-top: 0;
67
+ background-image: url('../images/shield.png');
68
+ background-repeat: no-repeat;
69
+ background-position: -40px -20px;
70
+ margin-bottom: 210px;
71
+ }
72
+ .container-inner {
73
+ width: 1200px;
74
+ margin: auto;
75
+ background-color: rgba(223, 227, 228, 0.75);
76
+ padding-bottom: 40px;
77
+ padding-top: 40px;
78
+ border-radius: 15px;
79
+ }
80
+ .header-content {
81
+ padding: 0;
82
+ width: 1000px;
83
+ }
84
+ .title1 {
85
+ font-size: 80px;
86
+ font-family: 'Vollkorn', serif;
87
+ color: #404040;
88
+ text-align: center;
89
+ padding-top: 40px;
90
+ padding-bottom: 100px;
91
+ }
92
+ #icon {
93
+ margin-top: -18px;
94
+ }
95
+ .subtext {
96
+ font-size: 25px;
97
+ font-style: italic;
98
+ color: #08b;
99
+ text-align: right;
100
+ padding-right: 250px;
101
+ }
102
+ .bg-primary {
103
+ background-color: #00468b;
104
+ }
105
+ .navbar-default .nav > li > a,
106
+ .navbar-default .nav > li > a:focus {
107
+ color: #08b;
108
+ }
109
+ .navbar-default .nav > li > a,
110
+ .navbar-default .nav > li > a:hover {
111
+ color: #08b;
112
+ }
113
+ .navbar-default .nav > li > a,
114
+ .navbar-default .nav > li > a:focus:hover {
115
+ color: #08b;
116
+ }
117
+ .text-faded {
118
+ font-size: 25px;
119
+ font-family: 'Vollkorn', serif;
120
+ }
121
+ .section-heading {
122
+ font-family: 'Vollkorn', serif;
123
+ font-size: 45px;
124
+ padding-bottom: 10px;
125
+ }
126
+ hr {
127
+ border-color: #00468b;
128
+ padding-bottom: 10px;
129
+ }
130
+ .description {
131
+ margin-top: 20px;
132
+ padding-bottom: 200px;
133
+ }
134
+ .description li {
135
+ font-family: 'Vollkorn', serif;
136
+ font-size: 25px;
137
+ color: #525252;
138
+ margin-left: 28%;
139
+ padding-top: 5px;
140
+ }
141
+ .gap {
142
+ margin-top: 200px;
143
+ }
144
+ .troubleshootingtext {
145
+ color: rgba(255, 255, 255, 0.7);
146
+ padding-left: 30%;
147
+ }
148
+ .troubleshootingtext li {
149
+ list-style-type: circle;
150
+ font-size: 25px;
151
+ padding-bottom: 5px;
152
+ }
153
+ .overlay {
154
+ position: absolute;
155
+ top: 0;
156
+ left: 0;
157
+ width: 100%;
158
+ height: 100%;
159
+ z-index: 1000;
160
+ }
161
+ .block.response_body.json:hover {
162
+ cursor: pointer;
163
+ }
164
+ .backdrop {
165
+ color: blue;
166
+ }
167
+ #myModal {
168
+ height: 100%;
169
+ }
170
+ .modal-backdrop {
171
+ bottom: 0;
172
+ position: fixed;
173
+ }
174
+ .curl {
175
+ padding: 10px;
176
+ font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace;
177
+ font-size: 0.9em;
178
+ max-height: 400px;
179
+ margin-top: 5px;
180
+ overflow-y: auto;
181
+ background-color: #fcf6db;
182
+ border: 1px solid #e5e0c6;
183
+ border-radius: 4px;
184
+ }
185
+ .curl_title {
186
+ font-size: 1.1em;
187
+ margin: 0;
188
+ padding: 15px 0 5px;
189
+ font-family: 'Open Sans', 'Helvetica Neue', Arial, sans-serif;
190
+ font-weight: 500;
191
+ line-height: 1.1;
192
+ }
193
+ .footer {
194
+ display: none;
195
+ }
196
+ .swagger-section .swagger-ui-wrap h2 {
197
+ padding: 0;
198
+ }
199
+ h2 {
200
+ margin: 0;
201
+ margin-bottom: 5px;
202
+ }
203
+ .markdown p {
204
+ font-size: 15px;
205
+ font-family: 'Arvo', serif;
206
+ }
207
+ .swagger-section .swagger-ui-wrap .code {
208
+ font-size: 15px;
209
+ font-family: 'Arvo', serif;
210
+ }
211
+ .swagger-section .swagger-ui-wrap b {
212
+ font-family: 'Arvo', serif;
213
+ }
214
+ #signin:hover {
215
+ cursor: pointer;
216
+ }
217
+ .dropdown-menu {
218
+ padding: 15px;
219
+ }
220
+ .navbar-right .dropdown-menu {
221
+ left: 0;
222
+ right: auto;
223
+ }
224
+ #signinbutton {
225
+ width: 100%;
226
+ height: 32px;
227
+ font-size: 13px;
228
+ font-weight: bold;
229
+ color: #08b;
230
+ }
231
+ .navbar-default .nav > li .details {
232
+ color: #000000;
233
+ text-transform: none;
234
+ font-size: 15px;
235
+ font-weight: normal;
236
+ font-family: 'Open Sans', sans-serif;
237
+ font-style: italic;
238
+ line-height: 20px;
239
+ top: -2px;
240
+ }
241
+ .navbar-default .nav > li .details:hover {
242
+ color: black;
243
+ }
244
+ #signout {
245
+ width: 100%;
246
+ height: 32px;
247
+ font-size: 13px;
248
+ font-weight: bold;
249
+ color: #08b;
250
+ }
@@ -0,0 +1,26 @@
1
+ /* droid-sans-regular - latin */
2
+ @font-face {
3
+ font-family: 'Droid Sans';
4
+ font-style: normal;
5
+ font-weight: 400;
6
+ src: url('../fonts/droid-sans-v6-latin-regular.eot'); /* IE9 Compat Modes */
7
+ src: local('Droid Sans'), local('DroidSans'),
8
+ url('../fonts/droid-sans-v6-latin-regular.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
9
+ url('../fonts/droid-sans-v6-latin-regular.woff2') format('woff2'), /* Super Modern Browsers */
10
+ url('../fonts/droid-sans-v6-latin-regular.woff') format('woff'), /* Modern Browsers */
11
+ url('../fonts/droid-sans-v6-latin-regular.ttf') format('truetype'), /* Safari, Android, iOS */
12
+ url('../fonts/droid-sans-v6-latin-regular.svg#DroidSans') format('svg'); /* Legacy iOS */
13
+ }
14
+ /* droid-sans-700 - latin */
15
+ @font-face {
16
+ font-family: 'Droid Sans';
17
+ font-style: normal;
18
+ font-weight: 700;
19
+ src: url('../fonts/droid-sans-v6-latin-700.eot'); /* IE9 Compat Modes */
20
+ src: local('Droid Sans Bold'), local('DroidSans-Bold'),
21
+ url('../fonts/droid-sans-v6-latin-700.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
22
+ url('../fonts/droid-sans-v6-latin-700.woff2') format('woff2'), /* Super Modern Browsers */
23
+ url('../fonts/droid-sans-v6-latin-700.woff') format('woff'), /* Modern Browsers */
24
+ url('../fonts/droid-sans-v6-latin-700.ttf') format('truetype'), /* Safari, Android, iOS */
25
+ url('../fonts/droid-sans-v6-latin-700.svg#DroidSans') format('svg'); /* Legacy iOS */
26
+ }
@@ -1,7 +1,8 @@
1
1
  <!DOCTYPE html>
2
- <html data-swagger-options="<%= GrapeSwaggerRails.options.to_h.to_json %>">
2
+ <html data-swagger-options="<%= GrapeSwaggerRails.options.marshal_dump.to_json %>">
3
3
  <head>
4
4
  <title><%= GrapeSwaggerRails.options.app_name || 'Swagger UI' %></title>
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
5
6
  <link href='//fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'/>
6
7
  <%= stylesheet_link_tag 'grape_swagger_rails/application.css' %>
7
8
  <%= javascript_include_tag 'grape_swagger_rails/application.js' %>
@@ -9,11 +10,17 @@
9
10
  $(function () {
10
11
  var options = $("html").data('swagger-options');
11
12
 
13
+ var headers = {};
14
+ <% GrapeSwaggerRails.options.headers.each_with_index do |(key, value), index| %>
15
+ <%=raw "headers.header_#{index} = new SwaggerClient.ApiKeyAuthorization('#{CGI.escapeHTML(key)}', '#{CGI.escapeHTML(value)}', 'header');" %>
16
+ <% end %>
17
+
12
18
  window.swaggerUi = new SwaggerUi({
13
19
  url: options.app_url + options.url,
14
- dom_id:"swagger-ui-container",
20
+ dom_id: "swagger-ui-container",
15
21
  supportHeaderParams: true,
16
- supportedSubmitMethods: ['get', 'post', 'put', 'delete'],
22
+ supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
23
+ authorizations: headers,
17
24
  onComplete: function(swaggerApi, swaggerUi){
18
25
  if('console' in window) {
19
26
  console.log("Loaded SwaggerUI")
@@ -28,7 +35,8 @@
28
35
  console.log(data);
29
36
  }
30
37
  },
31
- docExpansion: "none"
38
+ docExpansion: options.doc_expansion,
39
+ apisSorter: "alpha"
32
40
  });
33
41
 
34
42
  $('#input_apiKey').change(function() {
@@ -40,17 +48,14 @@
40
48
  } else if (options.api_auth == 'bearer') {
41
49
  key = "Bearer " + key
42
50
  }
43
- window.authorizations.add("key", new ApiKeyAuthorization(options.api_key_name, key, options.api_key_type));
51
+ window.swaggerUi.api.clientAuthorizations.add("key", new SwaggerClient.ApiKeyAuthorization(options.api_key_name, key, options.api_key_type));
44
52
  } else {
45
- window.authorizations.add("key", null);
53
+ window.swaggerUi.api.clientAuthorizations.add("key", null);
46
54
  }
47
55
  });
48
56
 
49
- <% GrapeSwaggerRails.options.headers.each_pair do |key, value| %>
50
- <%=raw "window.authorizations.add('key', new ApiKeyAuthorization('#{CGI.escapeHTML(key)}', '#{CGI.escapeHTML(value)}', 'header'));" %>
51
- <% end %>
52
-
53
57
  window.swaggerUi.load();
58
+
54
59
  });
55
60
  </script>
56
61
  </head>