rswag-ui 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/Rakefile +27 -0
- data/app/controllers/rswag/ui/home_controller.rb +11 -0
- data/app/views/rswag/ui/home/index.html.erb +126 -0
- data/config/routes.rb +3 -0
- data/lib/generators/rswag/ui/custom/USAGE +8 -0
- data/lib/generators/rswag/ui/custom/custom_generator.rb +13 -0
- data/lib/generators/rswag/ui/install/USAGE +8 -0
- data/lib/generators/rswag/ui/install/install_generator.rb +18 -0
- data/lib/generators/rswag/ui/install/templates/rswag-ui.rb +9 -0
- data/lib/rswag/ui/configuration.rb +17 -0
- data/lib/rswag/ui/engine.rb +13 -0
- data/lib/rswag/ui/version.rb +5 -0
- data/lib/rswag/ui.rb +15 -0
- metadata +80 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4e3b19f5dfd370a427e561892e4c4af39c9642cf
|
4
|
+
data.tar.gz: 9c1820c91172f06387572f20a857c59ffca79693
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 701b71ac61693d763592ff9d61589bbae38a56403602f54cfddd3a98bd3e6af1d7257358d0d28b66f334b94658d35d5a8d877e64e33372b94faca6f4daafa214
|
7
|
+
data.tar.gz: eb47858f29f1a165ab7dd3e0b8082e48dfb5f47670764a47375855ebedc998b57e98261613ec96b640d3048a01e3c38b5bbea4baa96d79b9df78a009b84d082a
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2015 domaindrivendev
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'rswag-specs'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
Bundler::GemHelper.install_tasks
|
27
|
+
|
@@ -0,0 +1,126 @@
|
|
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="/assets/swagger-ui/images/favicon-32x32.png" sizes="32x32" />
|
7
|
+
<link rel="icon" type="image/png" href="/assets/swagger-ui/images/favicon-16x16.png" sizes="16x16" />
|
8
|
+
<link href='/assets/swagger-ui/css/typography.css' media='screen' rel='stylesheet' type='text/css'/>
|
9
|
+
<link href='/assets/swagger-ui/css/reset.css' media='screen' rel='stylesheet' type='text/css'/>
|
10
|
+
<link href='/assets/swagger-ui/css/screen.css' media='screen' rel='stylesheet' type='text/css'/>
|
11
|
+
<link href='/assets/swagger-ui/css/reset.css' media='print' rel='stylesheet' type='text/css'/>
|
12
|
+
<link href='/assets/swagger-ui/css/print.css' media='print' rel='stylesheet' type='text/css'/>
|
13
|
+
|
14
|
+
<script src='/assets/swagger-ui/lib/object-assign-pollyfill.js' type='text/javascript'></script>
|
15
|
+
<script src='/assets/swagger-ui/lib/jquery-1.8.0.min.js' type='text/javascript'></script>
|
16
|
+
<script src='/assets/swagger-ui/lib/jquery.slideto.min.js' type='text/javascript'></script>
|
17
|
+
<script src='/assets/swagger-ui/lib/jquery.wiggle.min.js' type='text/javascript'></script>
|
18
|
+
<script src='/assets/swagger-ui/lib/jquery.ba-bbq.min.js' type='text/javascript'></script>
|
19
|
+
<script src='/assets/swagger-ui/lib/handlebars-4.0.5.js' type='text/javascript'></script>
|
20
|
+
<script src='/assets/swagger-ui/lib/lodash.min.js' type='text/javascript'></script>
|
21
|
+
<script src='/assets/swagger-ui/lib/backbone-min.js' type='text/javascript'></script>
|
22
|
+
<script src='/assets/swagger-ui/swagger-ui.min.js' type='text/javascript'></script>
|
23
|
+
<script src='/assets/swagger-ui/lib/highlight.9.1.0.pack.js' type='text/javascript'></script>
|
24
|
+
<script src='/assets/swagger-ui/lib/highlight.9.1.0.pack_extended.js' type='text/javascript'></script>
|
25
|
+
<script src='/assets/swagger-ui/lib/jsoneditor.min.js' type='text/javascript'></script>
|
26
|
+
<script src='/assets/swagger-ui/lib/marked.js' type='text/javascript'></script>
|
27
|
+
<script src='/assets/swagger-ui/lib/swagger-oauth.js' type='text/javascript'></script>
|
28
|
+
|
29
|
+
<!-- Some basic translations -->
|
30
|
+
<!-- <script src='/assets/swagger-ui/lang/translator.js' type='text/javascript'></script> -->
|
31
|
+
<!-- <script src='/assets/swagger-ui/lang/ru.js' type='text/javascript'></script> -->
|
32
|
+
<!-- <script src='/assets/swagger-ui/lang/en.js' type='text/javascript'></script> -->
|
33
|
+
|
34
|
+
<script type="text/javascript">
|
35
|
+
$(function () {
|
36
|
+
hljs.configure({
|
37
|
+
highlightSizeThreshold: 5000
|
38
|
+
});
|
39
|
+
|
40
|
+
// Pre load translate...
|
41
|
+
if(window.SwaggerTranslator) {
|
42
|
+
window.SwaggerTranslator.translate();
|
43
|
+
}
|
44
|
+
window.swaggerUi = new SwaggerUi({
|
45
|
+
url: '<%= @swagger_endpoints.first.path %>',
|
46
|
+
dom_id: "swagger-ui-container",
|
47
|
+
supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
|
48
|
+
onComplete: function(swaggerApi, swaggerUi){
|
49
|
+
if(typeof initOAuth == "function") {
|
50
|
+
initOAuth({
|
51
|
+
clientId: "your-client-id",
|
52
|
+
clientSecret: "your-client-secret-if-required",
|
53
|
+
realm: "your-realms",
|
54
|
+
appName: "your-app-name",
|
55
|
+
scopeSeparator: " ",
|
56
|
+
additionalQueryStringParams: {}
|
57
|
+
});
|
58
|
+
}
|
59
|
+
|
60
|
+
if(window.SwaggerTranslator) {
|
61
|
+
window.SwaggerTranslator.translate();
|
62
|
+
}
|
63
|
+
},
|
64
|
+
onFailure: function(data) {
|
65
|
+
log("Unable to Load SwaggerUI");
|
66
|
+
},
|
67
|
+
docExpansion: "list",
|
68
|
+
jsonEditor: false,
|
69
|
+
defaultModelRendering: 'schema',
|
70
|
+
showRequestHeaders: 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="/assets/swagger-ui/images/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
|
+
<select id="select_document">
|
92
|
+
<% @swagger_endpoints.each do |endpoint| %>
|
93
|
+
<option value='<%= endpoint.path %>'><%= endpoint.title %></option>
|
94
|
+
<% end %>
|
95
|
+
</select>
|
96
|
+
<script type="text/javascript">
|
97
|
+
// Refresh the swagger-ui when a new document is selected
|
98
|
+
$('#select_document').change(function () {
|
99
|
+
$('#input_baseUrl').val($(this).val());
|
100
|
+
window.swaggerUi.headerView.showCustom();
|
101
|
+
});
|
102
|
+
</script>
|
103
|
+
<style>
|
104
|
+
#select_document {
|
105
|
+
border: none;
|
106
|
+
height: 1.85em;
|
107
|
+
border-radius: 4px;
|
108
|
+
-moz-border-radius: 4px;
|
109
|
+
-webkit-border-radius: 4px;
|
110
|
+
-o-border-radius: 4px;
|
111
|
+
-ms-border-radius: 4px;
|
112
|
+
-khtml-border-radius: 4px;
|
113
|
+
font-size: 0.85em;
|
114
|
+
font-weight: bold;
|
115
|
+
color: white;
|
116
|
+
background-color: #547f00;
|
117
|
+
}
|
118
|
+
</style>
|
119
|
+
</form>
|
120
|
+
</div>
|
121
|
+
</div>
|
122
|
+
|
123
|
+
<div id="message-bar" class="swagger-ui-wrap" data-sw-translate> </div>
|
124
|
+
<div id="swagger-ui-container" class="swagger-ui-wrap"></div>
|
125
|
+
</body>
|
126
|
+
</html>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module Rswag
|
4
|
+
module Ui
|
5
|
+
class CustomGenerator < Rails::Generators::Base
|
6
|
+
source_root File.expand_path('../../../../../../app/views/rswag/ui/home', __FILE__)
|
7
|
+
|
8
|
+
def add_custom_index
|
9
|
+
copy_file('index.html.erb', 'app/views/rswag/ui/home/index.html.erb')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module Rswag
|
4
|
+
module Ui
|
5
|
+
|
6
|
+
class InstallGenerator < Rails::Generators::Base
|
7
|
+
source_root File.expand_path('../templates', __FILE__)
|
8
|
+
|
9
|
+
def add_initializer
|
10
|
+
template('rswag-ui.rb', 'config/initializers/rswag-ui.rb')
|
11
|
+
end
|
12
|
+
|
13
|
+
def add_routes
|
14
|
+
route("mount Rswag::Ui::Engine => '/api-docs'")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Rswag::Ui.configure do |c|
|
2
|
+
|
3
|
+
# List the Swagger endpoints that you want to be documented through the swagger-ui
|
4
|
+
# The first parameter is the path (absolute or relative to the UI host) to the corresponding
|
5
|
+
# JSON endpoint and the second is a title that will be displayed in the document selector
|
6
|
+
# NOTE: If you're using rspec-api to expose Swagger files (under swagger_root) as JSON endpoints,
|
7
|
+
# then the list below should correspond to the relative paths for those endpoints
|
8
|
+
c.swagger_endpoint '/api-docs/v1/swagger.json', 'API V1 Docs'
|
9
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
|
3
|
+
module Rswag
|
4
|
+
module Ui
|
5
|
+
class Configuration
|
6
|
+
attr_reader :swagger_endpoints
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@swagger_endpoints = []
|
10
|
+
end
|
11
|
+
|
12
|
+
def swagger_endpoint(path, title)
|
13
|
+
@swagger_endpoints << OpenStruct.new(path: path, title: title)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Rswag
|
2
|
+
module Ui
|
3
|
+
class Engine < ::Rails::Engine
|
4
|
+
isolate_namespace Rswag::Ui
|
5
|
+
|
6
|
+
initializer 'rswag-ui.initialize' do |app|
|
7
|
+
if app.config.respond_to?(:assets)
|
8
|
+
app.config.assets.precompile += [ 'swagger-ui/*' ]
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/rswag/ui.rb
ADDED
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rswag-ui
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Richie Morris
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-10-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: '3.1'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '5.1'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.1'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '5.1'
|
33
|
+
description: Expose beautiful API documentation, that's powered by Swagger JSON endpoints,
|
34
|
+
including a UI to explore and test operations
|
35
|
+
email:
|
36
|
+
- domaindrivendev@gmail.com
|
37
|
+
executables: []
|
38
|
+
extensions: []
|
39
|
+
extra_rdoc_files: []
|
40
|
+
files:
|
41
|
+
- MIT-LICENSE
|
42
|
+
- Rakefile
|
43
|
+
- app/controllers/rswag/ui/home_controller.rb
|
44
|
+
- app/views/rswag/ui/home/index.html.erb
|
45
|
+
- config/routes.rb
|
46
|
+
- lib/generators/rswag/ui/custom/USAGE
|
47
|
+
- lib/generators/rswag/ui/custom/custom_generator.rb
|
48
|
+
- lib/generators/rswag/ui/install/USAGE
|
49
|
+
- lib/generators/rswag/ui/install/install_generator.rb
|
50
|
+
- lib/generators/rswag/ui/install/templates/rswag-ui.rb
|
51
|
+
- lib/rswag/ui.rb
|
52
|
+
- lib/rswag/ui/configuration.rb
|
53
|
+
- lib/rswag/ui/engine.rb
|
54
|
+
- lib/rswag/ui/version.rb
|
55
|
+
homepage: https://github.com/domaindrivendev/rswag
|
56
|
+
licenses:
|
57
|
+
- MIT
|
58
|
+
metadata: {}
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options: []
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
requirements: []
|
74
|
+
rubyforge_project:
|
75
|
+
rubygems_version: 2.4.5
|
76
|
+
signing_key:
|
77
|
+
specification_version: 4
|
78
|
+
summary: A Rails Engine that includes swagger-ui and powers it from configured Swagger
|
79
|
+
endpoints
|
80
|
+
test_files: []
|