swagger_ui_static_engine 2.1.4

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e23c96bff6a4a0342ddeff91bac1f29bbdedf389
4
+ data.tar.gz: 0068d2d6d8c46396d0ecd8d71e6d77e25dc4a0ee
5
+ SHA512:
6
+ metadata.gz: cb2d47c6441ddb13f72c9246dd8869a8ac486e4f960ca43ba8ad5ba19ae94e47aa92161f3e800398bf7984587187f71dac9106506de3f51b60c7ecd9c4319f0c
7
+ data.tar.gz: 365cd9d99ce2a1c87e046c6cafeba88b304504b6f14d7fe6078c570743e0139a62b4bf4d7d081b6959ca61f2a6b785c96baa4f57a5da36abfbe011d7fc53bb7b
data/README.md ADDED
@@ -0,0 +1,87 @@
1
+ # Swagger UI Static Engine
2
+
3
+ I was documenting my API. I wanted to include [Swagger UI](http://swagger.io/swagger-ui/) as simply as possible.
4
+
5
+ Swagger UI is schweet, because, as they say:
6
+
7
+ > [_Swagger UI is a dependency-free collection of HTML, Javascript, and CSS assets ... just clone this repo and use the
8
+ pre-built files in the dist folder_](https://github.com/swagger-api/swagger-ui#download)
9
+
10
+ At first, I just copied the `dist` folder into my `/public` directory. Awesome! It's self-contained and just works.
11
+
12
+ But then, I had 25k lines of code in my git repo that, didn't belong there. So, I looked for more elegant ways
13
+ to include it in my project ...
14
+
15
+ I found some nice projects like:
16
+
17
+ * https://github.com/batdevis/swagger_engine
18
+ * https://github.com/d4be4st/swagger-ui_rails
19
+
20
+ The problem is, these projects had fallen out of date. I cloned them and tried to update them, but it was
21
+ complicated to just, copy the new swagger-ui/dist folder over, because these folks had really wired them up in the asset
22
+ pipeline and, in order to update them I had to mangle / merge / adapt the Swagger UI quite a bit. I thought, what I
23
+ really wanted was just, the static files, in a separate git repo, in an engine, that I could keep up to date, edit simply
24
+ (if later I want to tweak the look of things, etc).
25
+
26
+ So, that's what I have done here. It's mostly just the [Swagger UI
27
+ dist](https://github.com/swagger-api/swagger-ui/tree/master/dist) folder, in the public directory of the engine.
28
+
29
+
30
+ ## Swagger UI Version
31
+
32
+ **Contains Swagger UI version: 2.1.4**
33
+
34
+ The version number of this RubyGem will mirror Swagger UI's ...
35
+
36
+
37
+ ## Philosophy
38
+
39
+ This isn't really a gem that you configure, it's a gem that you fork and modify. I'm purposefully trying to alter the
40
+ static Swagger UI files, as little as possible. The more mods I make, the harder this will be to keep up with the
41
+ Swagger UI project. Additionally, there's no way for me to anticipate exactly how I will want to modify the Swagger UI
42
+ files to customize them for my project. I plan to make any customizations that I want, by editing the files directly in
43
+ this repo.
44
+
45
+
46
+ ## Install
47
+
48
+ _config/initializers/swagger_ui_static_engine.rb_
49
+
50
+ SwaggerUiStaticEngine::Engine.mount_path = "/api/docs" # the path to your swagger-ui page, when you have mounted it
51
+ SwaggerUiStaticEngine::Engine.swagger_url = "/api/swagger.json" # the path to your swagger.json file
52
+
53
+ _config/routes.rb_
54
+
55
+ Rails.application.routes.draw do
56
+ mount SwaggerUiStaticEngine::Engine, at: '/docs'
57
+ end
58
+
59
+
60
+ If you are including this inside another engine (as I am, my 'Api' engine), you will need these extra files:
61
+
62
+ _lib/yourengine.rb_
63
+
64
+ require 'swagger_ui_static_engine'
65
+
66
+ _lib/yourengine/yourengine.rb_
67
+
68
+ module YourEngine
69
+ class Engine < ::Rails::Engine
70
+ # combine this engine's static assets with the static assets of the hosting site
71
+ initializer "static assets" do |app|
72
+ app.middleware.insert_before(::ActionDispatch::Static, ::ActionDispatch::Static, "#{root}/public")
73
+ end
74
+ end
75
+ end
76
+
77
+
78
+ ## Updating
79
+
80
+ wget https://github.com/swagger-api/swagger-ui/archive/master.zip && mv master.zip swagger-ui-master.zip
81
+ unzip swagger-ui-master.zip
82
+ cp -R swagger-ui-master/dist/ swagger_ui_static_engine/public
83
+ mv swagger_ui_static_engine/public/index.html swagger_ui_static_engine/app/views/swagger_ui_static_engine/index.html.erb
84
+ git diff
85
+ <edit index.html.erb to view & merge anything that was overwritten>
86
+
87
+
@@ -0,0 +1,8 @@
1
+ module SwaggerUiStaticEngine
2
+ class ApplicationController < ActionController::Base
3
+ def index
4
+ @mount_path = SwaggerUiStaticEngine::Engine.mount_path
5
+ @swagger_url = SwaggerUiStaticEngine::Engine.swagger_url
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,105 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>Swagger UI</title>
6
+ <link rel="icon" type="image/png" href="<%= @mount_path %>/images/favicon-32x32.png" sizes="32x32" />
7
+ <link rel="icon" type="image/png" href="<%= @mount_path %>/images/favicon-16x16.png" sizes="16x16" />
8
+ <link href='<%= @mount_path %>/css/typography.css' media='screen' rel='stylesheet' type='text/css'/>
9
+ <link href='<%= @mount_path %>/css/reset.css' media='screen' rel='stylesheet' type='text/css'/>
10
+ <link href='<%= @mount_path %>/css/screen.css' media='screen' rel='stylesheet' type='text/css'/>
11
+ <link href='<%= @mount_path %>/css/reset.css' media='print' rel='stylesheet' type='text/css'/>
12
+ <link href='<%= @mount_path %>/css/print.css' media='print' rel='stylesheet' type='text/css'/>
13
+ <script src='<%= @mount_path %>/lib/jquery-1.8.0.min.js' type='text/javascript'></script>
14
+ <script src='<%= @mount_path %>/lib/jquery.slideto.min.js' type='text/javascript'></script>
15
+ <script src='<%= @mount_path %>/lib/jquery.wiggle.min.js' type='text/javascript'></script>
16
+ <script src='<%= @mount_path %>/lib/jquery.ba-bbq.min.js' type='text/javascript'></script>
17
+ <script src='<%= @mount_path %>/lib/handlebars-2.0.0.js' type='text/javascript'></script>
18
+ <script src='<%= @mount_path %>/lib/js-yaml.min.js' type='text/javascript'></script>
19
+ <script src='<%= @mount_path %>/lib/lodash.min.js' type='text/javascript'></script>
20
+ <script src='<%= @mount_path %>/lib/backbone-min.js' type='text/javascript'></script>
21
+ <script src='<%= @mount_path %>/swagger-ui.js' type='text/javascript'></script>
22
+ <script src='<%= @mount_path %>/lib/highlight.9.1.0.pack.js' type='text/javascript'></script>
23
+ <script src='<%= @mount_path %>/lib/highlight.9.1.0.pack_extended.js' type='text/javascript'></script>
24
+ <script src='<%= @mount_path %>/lib/jsoneditor.min.js' type='text/javascript'></script>
25
+ <script src='<%= @mount_path %>/lib/marked.js' type='text/javascript'></script>
26
+ <script src='<%= @mount_path %>/lib/swagger-oauth.js' type='text/javascript'></script>
27
+
28
+ <!-- Some basic translations -->
29
+ <!-- <script src='lang/translator.js' type='text/javascript'></script> -->
30
+ <!-- <script src='lang/ru.js' type='text/javascript'></script> -->
31
+ <!-- <script src='lang/en.js' type='text/javascript'></script> -->
32
+
33
+ <script type="text/javascript">
34
+ $(function () {
35
+ var url = window.location.search.match(/url=([^&]+)/);
36
+ if (url && url.length > 1) {
37
+ url = decodeURIComponent(url[1]);
38
+ } else {
39
+ url = "<%= @swagger_url %>";
40
+ }
41
+
42
+ hljs.configure({
43
+ highlightSizeThreshold: 5000
44
+ });
45
+
46
+ // Pre load translate...
47
+ if(window.SwaggerTranslator) {
48
+ window.SwaggerTranslator.translate();
49
+ }
50
+ window.swaggerUi = new SwaggerUi({
51
+ url: url,
52
+ dom_id: "swagger-ui-container",
53
+ supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
54
+ onComplete: function(swaggerApi, swaggerUi){
55
+ if(typeof initOAuth == "function") {
56
+ initOAuth({
57
+ clientId: "your-client-id",
58
+ clientSecret: "your-client-secret-if-required",
59
+ realm: "your-realms",
60
+ appName: "your-app-name",
61
+ scopeSeparator: ",",
62
+ additionalQueryStringParams: {}
63
+ });
64
+ }
65
+
66
+ if(window.SwaggerTranslator) {
67
+ window.SwaggerTranslator.translate();
68
+ }
69
+ },
70
+ onFailure: function(data) {
71
+ log("Unable to Load SwaggerUI");
72
+ },
73
+ docExpansion: "none",
74
+ jsonEditor: false,
75
+ defaultModelRendering: 'schema',
76
+ showRequestHeaders: false
77
+ });
78
+
79
+ window.swaggerUi.load();
80
+
81
+ function log() {
82
+ if ('console' in window) {
83
+ console.log.apply(console, arguments);
84
+ }
85
+ }
86
+ });
87
+ </script>
88
+ </head>
89
+
90
+ <body class="swagger-section">
91
+ <div id='header'>
92
+ <div class="swagger-ui-wrap">
93
+ <a id="logo" href="http://swagger.io"><img class="logo__img" alt="swagger" height="30" width="30" src="images/logo_small.png" /><span class="logo__title">swagger</span></a>
94
+ <form id='api_selector'>
95
+ <div class='input'><input placeholder="http://example.com/api" id="input_baseUrl" name="baseUrl" type="text"/></div>
96
+ <div id='auth_container'></div>
97
+ <div class='input'><a id="explore" class="header__btn" href="#" data-sw-translate>Explore</a></div>
98
+ </form>
99
+ </div>
100
+ </div>
101
+
102
+ <div id="message-bar" class="swagger-ui-wrap" data-sw-translate>&nbsp;</div>
103
+ <div id="swagger-ui-container" class="swagger-ui-wrap"></div>
104
+ </body>
105
+ </html>
metadata ADDED
@@ -0,0 +1,48 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: swagger_ui_static_engine
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.1.4
5
+ platform: ruby
6
+ authors:
7
+ - Kevin Trowbridge
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-05-05 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ - kevinmtrowbridge@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - app/controllers/swagger_ui_static_engine/application_controller.rb
21
+ - app/views/swagger_ui_static_engine/index.html.erb
22
+ - README.md
23
+ homepage: https://github.com/kevinmtrowbridge/swagger_ui_static_engine
24
+ licenses:
25
+ - Apache-2.0
26
+ metadata: {}
27
+ post_install_message:
28
+ rdoc_options: []
29
+ require_paths:
30
+ - lib
31
+ required_ruby_version: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - '>='
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ required_rubygems_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ requirements: []
42
+ rubyforge_project:
43
+ rubygems_version: 2.0.14.1
44
+ signing_key:
45
+ specification_version: 4
46
+ summary: Mount Swagger UI in a Rails app, via an engine, in as simple, editable, maintainable,
47
+ STATIC way, as possible.
48
+ test_files: []