grape-swagger-ui 0.0.9 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/CHANGELOG.md +39 -0
  4. data/README.md +11 -15
  5. data/app/views/layouts/swagger.html.erb +75 -61
  6. data/lib/generators/swagger/layout/templates/swagger.html.haml +67 -20
  7. data/lib/grape-swagger-ui/version.rb +1 -1
  8. data/vendor/assets/fonts/DroidSans-Bold.ttf +0 -0
  9. data/vendor/assets/fonts/DroidSans.ttf +0 -0
  10. data/vendor/assets/images/collapse.gif +0 -0
  11. data/vendor/assets/images/expand.gif +0 -0
  12. data/vendor/assets/images/favicon-16x16.png +0 -0
  13. data/vendor/assets/images/favicon-32x32.png +0 -0
  14. data/vendor/assets/images/favicon.ico +0 -0
  15. data/vendor/assets/javascripts/lang/en.js +56 -0
  16. data/vendor/assets/javascripts/lang/es.js +53 -0
  17. data/vendor/assets/javascripts/lang/fr.js +54 -0
  18. data/vendor/assets/javascripts/lang/geo.js +56 -0
  19. data/vendor/assets/javascripts/lang/it.js +52 -0
  20. data/vendor/assets/javascripts/lang/ja.js +53 -0
  21. data/vendor/assets/javascripts/lang/pl.js +53 -0
  22. data/vendor/assets/javascripts/lang/pt.js +53 -0
  23. data/vendor/assets/javascripts/lang/ru.js +56 -0
  24. data/vendor/assets/javascripts/lang/tr.js +53 -0
  25. data/vendor/assets/javascripts/lang/translator.js +39 -0
  26. data/vendor/assets/javascripts/lang/zh-cn.js +53 -0
  27. data/vendor/assets/javascripts/lib/backbone-min.js +14 -37
  28. data/vendor/assets/javascripts/lib/handlebars-2.0.0.js +28 -0
  29. data/vendor/assets/javascripts/lib/highlight.9.1.0.pack.js +2 -0
  30. data/vendor/assets/javascripts/lib/highlight.9.1.0.pack_extended.js +34 -0
  31. data/vendor/assets/javascripts/lib/jquery-1.8.0.min.js +1 -1
  32. data/vendor/assets/javascripts/lib/js-yaml.min.js +3 -0
  33. data/vendor/assets/javascripts/lib/jsoneditor.min.js +11 -0
  34. data/vendor/assets/javascripts/lib/lodash.min.js +102 -0
  35. data/vendor/assets/javascripts/lib/marked.js +1272 -0
  36. data/vendor/assets/javascripts/lib/object-assign-pollyfill.js +23 -0
  37. data/vendor/assets/javascripts/lib/swagger-oauth.js +193 -65
  38. data/vendor/assets/javascripts/swagger-ui.js +22064 -2110
  39. data/vendor/assets/javascripts/swagger-ui.min.js +9 -0
  40. data/vendor/assets/javascripts/swagger_ui.js +11 -8
  41. data/vendor/assets/stylesheets/print.css +1362 -0
  42. data/vendor/assets/stylesheets/reset_2.css +125 -0
  43. data/vendor/assets/stylesheets/screen.css +310 -45
  44. data/vendor/assets/stylesheets/style.css +250 -0
  45. data/vendor/assets/stylesheets/swagger_ui.css +7 -2
  46. data/vendor/assets/stylesheets/swagger_ui_print.css +15 -0
  47. data/vendor/assets/stylesheets/swagger_ui_screen.css +16 -0
  48. data/vendor/assets/stylesheets/typography.css +14 -0
  49. metadata +37 -8
  50. data/vendor/assets/javascripts/lib/handlebars-1.0.0.js +0 -2278
  51. data/vendor/assets/javascripts/lib/highlight.7.3.pack.js +0 -1
  52. data/vendor/assets/javascripts/lib/shred.bundle.js +0 -2765
  53. data/vendor/assets/javascripts/lib/shred/content.js +0 -193
  54. data/vendor/assets/javascripts/lib/swagger.js +0 -1653
  55. data/vendor/assets/javascripts/lib/underscore-min.js +0 -32
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 02eba1747238825a0d90879adb81e84c87c805ff
4
- data.tar.gz: 2a4c67cf5189e641a3e27f937bc4a6387d5505bb
3
+ metadata.gz: c7e74c225b173b884858eff45aa6dda7b451d9bf
4
+ data.tar.gz: 40ce002bcd5c185be1fc5ca2bbc11bea0101fe9c
5
5
  SHA512:
6
- metadata.gz: 319eddc0d9ac5472cf638109d97ff39f6a5a6d0e67d791cfa6d88a55428eeaaafc64ad85f883bd3420f249eb98b9340b7340e93044808a7e6f81e87160a972aa
7
- data.tar.gz: bb394e1d2170e96855e5eb53eabada6f4961d5614475c0692c333968c74c015afaf7ddf61746d1f75c0c7dce50699faf7ed6c75d5f47b4b56e9189c8f711ab1b
6
+ metadata.gz: 80a484beff310bd15f208ee157238b7f8a4f08e99fb7b44ee4627e10281a87d3786703a35772a943c9da6f89259235c3c1e14356ce337417e8cec9fe4ae941c0
7
+ data.tar.gz: 7d49aacaf6fe37e28da760666ed11543a85bf75e461502e6814aff13f0c34f7b3c5aa68935e8503b82ac6ff72f8bb10b4d7ed3dc9f83dc030a5b3eadbef7979c
data/.gitignore CHANGED
@@ -19,3 +19,4 @@ tmp
19
19
  *.iml
20
20
  atlassian-ide-plugin.xml
21
21
  .idea/
22
+ .DS_Store
@@ -0,0 +1,39 @@
1
+ # Change Log
2
+
3
+ ## [Unreleased](https://github.com/kendrikat/grape-swagger-ui/tree/HEAD)
4
+
5
+ [Full Changelog](https://github.com/kendrikat/grape-swagger-ui/compare/v0.0.3...HEAD)
6
+
7
+ **Closed issues:**
8
+
9
+ - Swagger UI needs to be updated [\#9](https://github.com/kendrikat/grape-swagger-ui/issues/9)
10
+
11
+ ## [v0.0.3](https://github.com/kendrikat/grape-swagger-ui/tree/v0.0.3) (2016-08-09)
12
+ [Full Changelog](https://github.com/kendrikat/grape-swagger-ui/compare/v0.0.2...v0.0.3)
13
+
14
+ **Closed issues:**
15
+
16
+ - Routing not working [\#6](https://github.com/kendrikat/grape-swagger-ui/issues/6)
17
+ - haml issue in rails 4 [\#4](https://github.com/kendrikat/grape-swagger-ui/issues/4)
18
+
19
+ **Merged pull requests:**
20
+
21
+ - Support swagger spec 2.0 [\#8](https://github.com/kendrikat/grape-swagger-ui/pull/8) ([dangnm](https://github.com/dangnm))
22
+
23
+ ## [v0.0.2](https://github.com/kendrikat/grape-swagger-ui/tree/v0.0.2) (2015-01-14)
24
+ [Full Changelog](https://github.com/kendrikat/grape-swagger-ui/compare/v0.0.1...v0.0.2)
25
+
26
+ **Closed issues:**
27
+
28
+ - License missing from gemspec [\#2](https://github.com/kendrikat/grape-swagger-ui/issues/2)
29
+
30
+ **Merged pull requests:**
31
+
32
+ - update for swagger-ui 2.0.24 [\#5](https://github.com/kendrikat/grape-swagger-ui/pull/5) ([alexagranov](https://github.com/alexagranov))
33
+ - assets path mistake in swagger-ui.js [\#3](https://github.com/kendrikat/grape-swagger-ui/pull/3) ([dfang](https://github.com/dfang))
34
+ - Optional form fields are not being send with request [\#1](https://github.com/kendrikat/grape-swagger-ui/pull/1) ([camol](https://github.com/camol))
35
+
36
+ ## [v0.0.1](https://github.com/kendrikat/grape-swagger-ui/tree/v0.0.1) (2013-02-25)
37
+
38
+
39
+ \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
data/README.md CHANGED
@@ -5,12 +5,7 @@ Grape::Swagger::Ui
5
5
 
6
6
  TODO/WIP: Write a gem description
7
7
 
8
- Integrates [swagger-ui] with your "grapified" Rails3 application.
9
-
10
- ** UPDATE FOR 0.0.9 **
11
- -
12
-
13
- - The property for specifying your Swagger endpoint on SwaggerUi has been renamed from 'discoveryUrl' to just 'url'. This has been updated in the index page template 'swagger.html.erb' but you will need to either regenerate or manually edit your existing page.
8
+ Integrates [swagger-ui] with your "grapified" Rails application.
14
9
 
15
10
  ## Dependencies
16
11
 
@@ -36,11 +31,15 @@ Or install it yourself as:
36
31
 
37
32
  ## Usage example:
38
33
 
39
- # class YourAPI < Grape::API
40
- add_swagger_documentation :format => :json,
41
- :api_version => 'v1',
42
- :base_path => "http://#{Rails.configuration.default_host}/api/",
43
- :hide_documentation_path => true
34
+ class YourAPI < Grape::API
35
+ version 'v1'
36
+ format :json
37
+ ...
38
+ add_swagger_documentation :add_version => true,
39
+ :base_path => '/api'
40
+ end
41
+
42
+ *See https://github.com/ruby-grape/grape-swagger#configure for more configuration settings.*
44
43
 
45
44
  If your api path is "api/v1" just go to
46
45
 
@@ -57,11 +56,8 @@ and change the initializer.
57
56
  Since this is a seperate layout and if you want to use this in your staging environment you need to precompile it.
58
57
 
59
58
  #staging.rb
60
- config.assets.precompile += ["swagger_ui.css", "swagger_ui.js"]
61
-
62
- ## Version
59
+ config.assets.precompile += %w(swagger_ui.js swagger_ui.css swagger_ui_print.css swagger_ui_screen.css)
63
60
 
64
- 0.0.9
65
61
 
66
62
  ## Contributing
67
63
 
@@ -4,79 +4,93 @@
4
4
  <title>Swagger UI</title>
5
5
  <%= javascript_include_tag :swagger_ui %>
6
6
  <%= stylesheet_link_tag "//fonts.googleapis.com/css?family=Droid+Sans:400,700" %>
7
- <%= stylesheet_link_tag :swagger_ui, :media => :all %>
7
+ <%= stylesheet_link_tag :swagger_ui_screen, :media => :screen %>
8
+ <%= stylesheet_link_tag :swagger_ui_print, :media => :print %>
8
9
  <%= csrf_meta_tags %>
9
10
 
10
- <script>
11
+ <script type="text/javascript">
12
+ $(function () {
13
+ var url = window.location.search.match(/url=([^&]+)/);
14
+ if (url && url.length > 1) {
15
+ url = decodeURIComponent(url[1]);
16
+ } else {
17
+ url = "http://<%= request.host%>:<%=request.port%>/api/v1/swagger_doc";
18
+ }
11
19
 
12
- $(function () {
13
- $.ajaxPrefilter(function (o, options) {
14
- options.headers = {'X-CSRF-Token': '#{form_authenticity_token.to_s}'}
15
- });
20
+ hljs.configure({
21
+ highlightSizeThreshold: 5000
16
22
  });
17
23
 
18
- $(function () {
19
- window.swaggerUi = new SwaggerUi({
20
- url: "http://<%= request.host%>:<%=request.port%>/api/swagger_doc",
21
- apiKey: "",
22
- dom_id: "swagger-ui-container",
23
- supportHeaderParams: false,
24
- supportedSubmitMethods: ['get', 'post', 'put'],
25
- onComplete: function (swaggerApi, swaggerUi) {
26
- log("Loaded SwaggerUI");
27
- if (typeof initOAuth == "function") {
28
- /*
29
- initOAuth({
30
- clientId: "your-client-id",
31
- realm: "your-realms",
32
- appName: "your-app-name"
33
- });
34
- */
35
- }
36
- $('pre code').each(function (i, e) {
37
- hljs.highlightBlock(e)
38
- });
39
- },
40
- onFailure: function (data) {
41
- log("Unable to Load SwaggerUI");
42
- },
43
- docExpansion: "none",
44
- sorter: "alpha"
45
- });
24
+ // Pre load translate...
25
+ if(window.SwaggerTranslator) {
26
+ window.SwaggerTranslator.translate();
27
+ }
28
+ window.swaggerUi = new SwaggerUi({
29
+ url: url,
30
+ dom_id: "swagger-ui-container",
31
+ supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
32
+ onComplete: function(swaggerApi, swaggerUi){
33
+ if(typeof initOAuth == "function") {
34
+ initOAuth({
35
+ clientId: "your-client-id",
36
+ clientSecret: "your-client-secret-if-required",
37
+ realm: "your-realms",
38
+ appName: "your-app-name",
39
+ scopeSeparator: ",",
40
+ additionalQueryStringParams: {}
41
+ });
42
+ }
46
43
 
47
- $('#input_apiKey').change(function () {
48
- var key = $('#input_apiKey')[0].value;
49
- log("key: " + key);
50
- if (key && key.trim() != "") {
51
- log("added key " + key);
52
- window.authorizations.add("key", new ApiKeyAuthorization("api_key", key, "query"));
53
- }
54
- })
55
- window.swaggerUi.load();
44
+ if(window.SwaggerTranslator) {
45
+ window.SwaggerTranslator.translate();
46
+ }
47
+ },
48
+ onFailure: function(data) {
49
+ log("Unable to Load SwaggerUI");
50
+ },
51
+ docExpansion: "none",
52
+ jsonEditor: false,
53
+ defaultModelRendering: 'schema',
54
+ showRequestHeaders: false
56
55
  });
57
56
 
57
+ $('#input_apiKey').change(function() {
58
+ var key = $('#input_apiKey')[0].value;
59
+ if(key && key.trim() != "") {
60
+ swaggerUi.api.clientAuthorizations.add("key", new SwaggerClient.ApiKeyAuthorization("api_key", key, "query"));
61
+ }
62
+ })
58
63
 
64
+ window.swaggerUi.load();
65
+
66
+ function log() {
67
+ if ('console' in window) {
68
+ console.log.apply(console, arguments);
69
+ }
70
+ }
71
+ });
59
72
  </script>
73
+
60
74
  </head>
61
- <body class="swagger-section">
62
- <div id="header">
63
- <div class="swagger-ui-wrap">
64
- <a href="http://swagger.wordnik.com" id="logo">Swagger</a>
65
75
 
66
- <form id="api_selector">
67
- <div class="input">
68
- <input id="input_baseUrl" name="baseUrl" placeholder="http://example.com/api" type="text"></input>
69
- </div>
70
- <div class="input">
71
- <input id="input_apiKey" name="apiKey" placeholder="api_key" type="text"></input>
72
- </div>
73
- <div class="input">
74
- <a href="#" id="explore">Explore</a>
75
- </div>
76
- </form>
77
- </div>
76
+
77
+ <body class="swagger-section">
78
+ <div id='header'>
79
+ <div class="swagger-ui-wrap">
80
+ <a id="logo" href="http://swagger.io"><span class="logo__title">swagger</span></a>
81
+ <form id='api_selector'>
82
+ <div class='input'><input placeholder="http://example.com/api" id="input_baseUrl" name="baseUrl" type="text"/></div>
83
+ <div class="input">
84
+ <input id="input_apiKey" name="apiKey" placeholder="api_key" type="text"></input>
85
+ </div>
86
+ <div id='auth_container'></div>
87
+ <div class='input'><a id="explore" class="header__btn" href="#" data-sw-translate>Explore</a></div>
88
+ </form>
89
+ </div>
78
90
  </div>
79
- <div class="swagger-ui-wrap" id="message-bar">&nbsp;</div>
80
- <div class="swagger-ui-wrap" id="swagger-ui-container"></div>
91
+
92
+ <div id="message-bar" class="swagger-ui-wrap" data-sw-translate>&nbsp;</div>
93
+ <div id="swagger-ui-container" class="swagger-ui-wrap"></div>
81
94
  </body>
95
+
82
96
  </html>
@@ -4,7 +4,8 @@
4
4
  %title Swagger UI
5
5
 
6
6
  = javascript_include_tag :swagger_ui
7
- = stylesheet_link_tag :swagger_ui, :media => :all
7
+ = stylesheet_link_tag :swagger_ui_screen, :media => :screen
8
+ = stylesheet_link_tag :swagger_ui_print, :media => :print
8
9
  = csrf_meta_tags
9
10
 
10
11
  :css
@@ -14,36 +15,82 @@
14
15
  margin-left: auto;
15
16
  margin-right: auto;
16
17
  }
17
-
18
- :javascript
19
- $(function(){
20
- $.ajaxPrefilter(function(o, options){
21
- options.headers = { 'X-CSRF-Token': '#{form_authenticity_token.to_s}' }
22
- });
23
- });
24
18
 
19
+ :javascript
25
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 = "http://#{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
+ }
26
36
  window.swaggerUi = new SwaggerUi({
27
- discoveryUrl: "http://#{request.host}:#{request.port}/api/swagger_doc.json",
28
- apiKey:"",
29
- dom_id:"swagger-ui-container",
30
- supportHeaderParams: false,
31
- supportedSubmitMethods: ['get', 'post', 'put']
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
32
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
+
33
72
  window.swaggerUi.load();
73
+
74
+ function log() {
75
+ if ('console' in window) {
76
+ console.log.apply(console, arguments);
77
+ }
78
+ }
34
79
  });
35
80
 
36
- %body
81
+ %body.swagger-section
37
82
  #header
38
83
  .swagger-ui-wrap
39
- %a#logo{ href: "http://swagger.wordnik.com" } Swagger
84
+ %a#logo{:href => "http://swagger.io"}
85
+ %span.logo__title swagger
40
86
  %form#api_selector
41
87
  .input
42
- %input#input_baseUrl{ placeholder: "http://example.com/api", name: "baseUrl", type: "text" }
88
+ %input#input_baseUrl{:name => "baseUrl", :placeholder => "http://example.com/api", :type => "text"}/
43
89
  .input
44
- %input#input_apiKey{ placeholder: "api_key", name: "apiKey", type: "text" }
90
+ %input#input_apiKey{:name => "apiKey", :placeholder => "api_key", :type => "text"}
91
+ #auth_container
45
92
  .input
46
- %a#explore{ href: "#"} Explore
93
+ %a#explore.header__btn{"data-sw-translate" => "", :href => "#"} Explore
94
+ #message-bar.swagger-ui-wrap{"data-sw-translate" => ""} &nbsp;
95
+ #swagger-ui-container.swagger-ui-wrap
47
96
 
48
- #message-bar.swagger-ui-wrap &nbsp;
49
- #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.0.9"
4
+ VERSION = "0.1.0"
5
5
  end
6
6
  end
7
7
  end
@@ -0,0 +1,56 @@
1
+ 'use strict';
2
+
3
+ /* jshint quotmark: double */
4
+ window.SwaggerTranslator.learn({
5
+ "Warning: Deprecated":"Warning: Deprecated",
6
+ "Implementation Notes":"Implementation Notes",
7
+ "Response Class":"Response Class",
8
+ "Status":"Status",
9
+ "Parameters":"Parameters",
10
+ "Parameter":"Parameter",
11
+ "Value":"Value",
12
+ "Description":"Description",
13
+ "Parameter Type":"Parameter Type",
14
+ "Data Type":"Data Type",
15
+ "Response Messages":"Response Messages",
16
+ "HTTP Status Code":"HTTP Status Code",
17
+ "Reason":"Reason",
18
+ "Response Model":"Response Model",
19
+ "Request URL":"Request URL",
20
+ "Response Body":"Response Body",
21
+ "Response Code":"Response Code",
22
+ "Response Headers":"Response Headers",
23
+ "Hide Response":"Hide Response",
24
+ "Headers":"Headers",
25
+ "Try it out!":"Try it out!",
26
+ "Show/Hide":"Show/Hide",
27
+ "List Operations":"List Operations",
28
+ "Expand Operations":"Expand Operations",
29
+ "Raw":"Raw",
30
+ "can't parse JSON. Raw result":"can't parse JSON. Raw result",
31
+ "Example Value":"Example Value",
32
+ "Model Schema":"Model Schema",
33
+ "Model":"Model",
34
+ "Click to set as parameter value":"Click to set as parameter value",
35
+ "apply":"apply",
36
+ "Username":"Username",
37
+ "Password":"Password",
38
+ "Terms of service":"Terms of service",
39
+ "Created by":"Created by",
40
+ "See more at":"See more at",
41
+ "Contact the developer":"Contact the developer",
42
+ "api version":"api version",
43
+ "Response Content Type":"Response Content Type",
44
+ "Parameter content type:":"Parameter content type:",
45
+ "fetching resource":"fetching resource",
46
+ "fetching resource list":"fetching resource list",
47
+ "Explore":"Explore",
48
+ "Show Swagger Petstore Example Apis":"Show Swagger Petstore Example Apis",
49
+ "Can't read from server. It may not have the appropriate access-control-origin settings.":"Can't read from server. It may not have the appropriate access-control-origin settings.",
50
+ "Please specify the protocol for":"Please specify the protocol for",
51
+ "Can't read swagger JSON from":"Can't read swagger JSON from",
52
+ "Finished Loading Resource Information. Rendering Swagger UI":"Finished Loading Resource Information. Rendering Swagger UI",
53
+ "Unable to read api":"Unable to read api",
54
+ "from path":"from path",
55
+ "server returned":"server returned"
56
+ });