grape_swagger_ui 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/Rakefile +24 -0
  4. data/app/assets/images/grape_swagger_ui/explorer_icons.png +0 -0
  5. data/app/assets/images/grape_swagger_ui/throbber.gif +0 -0
  6. data/app/assets/javascripts/grape_swagger_ui/application.js +24 -0
  7. data/app/assets/javascripts/grape_swagger_ui/backbone-min.js +38 -0
  8. data/app/assets/javascripts/grape_swagger_ui/handlebars-1.0.0.js +2278 -0
  9. data/app/assets/javascripts/grape_swagger_ui/highlight.7.3.pack.js +1 -0
  10. data/app/assets/javascripts/grape_swagger_ui/jquery-1.8.0.min.js +2 -0
  11. data/app/assets/javascripts/grape_swagger_ui/jquery.ba-bbq.min.js +18 -0
  12. data/app/assets/javascripts/grape_swagger_ui/jquery.slideto.min.js +1 -0
  13. data/app/assets/javascripts/grape_swagger_ui/jquery.wiggle.min.js +8 -0
  14. data/app/assets/javascripts/grape_swagger_ui/shred.bundle.js +2765 -0
  15. data/app/assets/javascripts/grape_swagger_ui/shred/content.js +193 -0
  16. data/app/assets/javascripts/grape_swagger_ui/swagger-oauth.js +211 -0
  17. data/app/assets/javascripts/grape_swagger_ui/swagger-ui.js +2324 -0
  18. data/app/assets/javascripts/grape_swagger_ui/swagger.js +1653 -0
  19. data/app/assets/javascripts/grape_swagger_ui/underscore-min.js +32 -0
  20. data/app/assets/stylesheets/grape_swagger_ui/application.css +15 -0
  21. data/app/assets/stylesheets/grape_swagger_ui/reset.css +125 -0
  22. data/app/assets/stylesheets/grape_swagger_ui/screen.css.scss +1224 -0
  23. data/app/controllers/grape_swagger_ui/api_doc_controller.rb +8 -0
  24. data/app/controllers/grape_swagger_ui/application_controller.rb +10 -0
  25. data/app/helpers/grape_swagger_ui/application_helper.rb +4 -0
  26. data/app/views/grape_swagger_ui/api_doc/index.html.erb +2 -0
  27. data/app/views/layouts/grape_swagger_ui/application.html.erb +55 -0
  28. data/config/routes.rb +3 -0
  29. data/lib/grape_swagger_ui.rb +11 -0
  30. data/lib/grape_swagger_ui/engine.rb +5 -0
  31. data/lib/grape_swagger_ui/version.rb +3 -0
  32. data/lib/tasks/grape_swagger_ui_tasks.rake +4 -0
  33. metadata +91 -0
@@ -0,0 +1,8 @@
1
+ require_dependency "grape_swagger_ui/application_controller"
2
+
3
+ module GrapeSwaggerUi
4
+ class ApiDocController < ApplicationController
5
+ def index
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,10 @@
1
+ module GrapeSwaggerUi
2
+ class ApplicationController < ActionController::Base
3
+
4
+ before_action GrapeSwaggerUi.authenticate_method, if: :require_authorization?
5
+
6
+ def require_authorization?
7
+ GrapeSwaggerUi.authenticate_method.is_a? Symbol
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,4 @@
1
+ module GrapeSwaggerUi
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,2 @@
1
+ <div id="message-bar" class="swagger-ui-wrap">&nbsp;</div>
2
+ <div id="swagger-ui-container" class="swagger-ui-wrap"></div>
@@ -0,0 +1,55 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>GrapeSwaggerUi</title>
5
+ <%= stylesheet_link_tag "grape_swagger_ui/application", media: "all" %>
6
+ <%= javascript_include_tag "grape_swagger_ui/application" %>
7
+ <%= csrf_meta_tags %>
8
+
9
+ <script type="text/javascript">
10
+ $(function () {
11
+ window.swaggerUi = new SwaggerUi({
12
+ url: '<%= GrapeSwaggerUi.url %>',
13
+ dom_id: '<%= GrapeSwaggerUi.dom_id %>',
14
+ supportedSubmitMethods: <%= GrapeSwaggerUi.supported_submit_methods.to_json.html_safe %>,
15
+ onComplete: function(swaggerApi, swaggerUi){
16
+ log("Loaded SwaggerUI");
17
+
18
+ if(typeof initOAuth == "function") {
19
+ /*
20
+ initOAuth({
21
+ clientId: "your-client-id",
22
+ realm: "your-realms",
23
+ appName: "your-app-name"
24
+ });
25
+ */
26
+ }
27
+ $('pre code').each(function(i, e) {
28
+ hljs.highlightBlock(e)
29
+ });
30
+ },
31
+ onFailure: function(data) {
32
+ log("Unable to Load SwaggerUI");
33
+ },
34
+ docExpansion: '<%= GrapeSwaggerUi.doc_expansion %>',
35
+ sorter : '<%= GrapeSwaggerUi.sorter %>'
36
+ });
37
+
38
+ $('#input_apiKey').change(function() {
39
+ var key = $('#input_apiKey')[0].value;
40
+ log("key: " + key);
41
+ if(key && key.trim() != "") {
42
+ log("added key " + key);
43
+ window.authorizations.add("key", new ApiKeyAuthorization("api_key", key, "query"));
44
+ }
45
+ })
46
+ window.swaggerUi.load();
47
+ });
48
+ </script>
49
+ </head>
50
+
51
+ <body class="swagger-section">
52
+ <%= yield %>
53
+ </body>
54
+ </html>
55
+
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ GrapeSwaggerUi::Engine.routes.draw do
2
+ root to: 'api_doc#index'
3
+ end
@@ -0,0 +1,11 @@
1
+ require "grape_swagger_ui/engine"
2
+
3
+ module GrapeSwaggerUi
4
+
5
+ mattr_accessor(:url) { '/api/swagger_doc' }
6
+ mattr_accessor(:doc_expansion) { 'none' }
7
+ mattr_accessor(:dom_id) { 'swagger-ui-container' }
8
+ mattr_accessor(:supported_submit_methods) { ['get', 'post', 'put', 'delete', 'patch'] }
9
+ mattr_accessor(:sorter) { 'alpha' }
10
+ mattr_accessor(:authenticate_method) { -> { puts 'No Authentication Required.' } }
11
+ end
@@ -0,0 +1,5 @@
1
+ module GrapeSwaggerUi
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace GrapeSwaggerUi
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module GrapeSwaggerUi
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :grape_swagger_ui do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: grape_swagger_ui
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ismail Akram
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-06-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 4.2.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 4.2.0
27
+ description: Swagger UI for Grapes in rails. this is using old version of swagger
28
+ UI, as there is some bug that not let display model schema in latest version and
29
+ also latest swagger-ui do not works great with grape-swagger
30
+ email:
31
+ - rubyonrails3@gmail.com
32
+ executables: []
33
+ extensions: []
34
+ extra_rdoc_files: []
35
+ files:
36
+ - MIT-LICENSE
37
+ - Rakefile
38
+ - app/assets/images/grape_swagger_ui/explorer_icons.png
39
+ - app/assets/images/grape_swagger_ui/throbber.gif
40
+ - app/assets/javascripts/grape_swagger_ui/application.js
41
+ - app/assets/javascripts/grape_swagger_ui/backbone-min.js
42
+ - app/assets/javascripts/grape_swagger_ui/handlebars-1.0.0.js
43
+ - app/assets/javascripts/grape_swagger_ui/highlight.7.3.pack.js
44
+ - app/assets/javascripts/grape_swagger_ui/jquery-1.8.0.min.js
45
+ - app/assets/javascripts/grape_swagger_ui/jquery.ba-bbq.min.js
46
+ - app/assets/javascripts/grape_swagger_ui/jquery.slideto.min.js
47
+ - app/assets/javascripts/grape_swagger_ui/jquery.wiggle.min.js
48
+ - app/assets/javascripts/grape_swagger_ui/shred.bundle.js
49
+ - app/assets/javascripts/grape_swagger_ui/shred/content.js
50
+ - app/assets/javascripts/grape_swagger_ui/swagger-oauth.js
51
+ - app/assets/javascripts/grape_swagger_ui/swagger-ui.js
52
+ - app/assets/javascripts/grape_swagger_ui/swagger.js
53
+ - app/assets/javascripts/grape_swagger_ui/underscore-min.js
54
+ - app/assets/stylesheets/grape_swagger_ui/application.css
55
+ - app/assets/stylesheets/grape_swagger_ui/reset.css
56
+ - app/assets/stylesheets/grape_swagger_ui/screen.css.scss
57
+ - app/controllers/grape_swagger_ui/api_doc_controller.rb
58
+ - app/controllers/grape_swagger_ui/application_controller.rb
59
+ - app/helpers/grape_swagger_ui/application_helper.rb
60
+ - app/views/grape_swagger_ui/api_doc/index.html.erb
61
+ - app/views/layouts/grape_swagger_ui/application.html.erb
62
+ - config/routes.rb
63
+ - lib/grape_swagger_ui.rb
64
+ - lib/grape_swagger_ui/engine.rb
65
+ - lib/grape_swagger_ui/version.rb
66
+ - lib/tasks/grape_swagger_ui_tasks.rake
67
+ homepage: https://github.com/rubyonrails3/grape-swagger-ui
68
+ licenses:
69
+ - MIT
70
+ metadata: {}
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubyforge_project:
87
+ rubygems_version: 2.2.2
88
+ signing_key:
89
+ specification_version: 4
90
+ summary: Swagger UI for Grapes in rails.
91
+ test_files: []