rswag-ui-2.1 2.9.1.ruby21
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 +7 -0
- data/MIT-LICENSE +20 -0
- data/Rakefile +27 -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 +16 -0
- data/lib/rswag/ui/basic_auth.rb +31 -0
- data/lib/rswag/ui/configuration.rb +44 -0
- data/lib/rswag/ui/engine.rb +25 -0
- data/lib/rswag/ui/index.erb +103 -0
- data/lib/rswag/ui/middleware.rb +54 -0
- data/lib/rswag/ui.rb +14 -0
- data/lib/tasks/rswag-ui_tasks.rake +12 -0
- data/node_modules/swagger-ui-dist/LICENSE +202 -0
- data/node_modules/swagger-ui-dist/NOTICE +2 -0
- data/node_modules/swagger-ui-dist/README.md +22 -0
- data/node_modules/swagger-ui-dist/absolute-path.js +14 -0
- data/node_modules/swagger-ui-dist/favicon-16x16.png +0 -0
- data/node_modules/swagger-ui-dist/favicon-32x32.png +0 -0
- data/node_modules/swagger-ui-dist/index.html +60 -0
- data/node_modules/swagger-ui-dist/index.js +17 -0
- data/node_modules/swagger-ui-dist/oauth2-redirect.html +75 -0
- data/node_modules/swagger-ui-dist/package.json +18 -0
- data/node_modules/swagger-ui-dist/swagger-ui-bundle.js +3 -0
- data/node_modules/swagger-ui-dist/swagger-ui-bundle.js.map +1 -0
- data/node_modules/swagger-ui-dist/swagger-ui-es-bundle-core.js +3 -0
- data/node_modules/swagger-ui-dist/swagger-ui-es-bundle-core.js.map +1 -0
- data/node_modules/swagger-ui-dist/swagger-ui-es-bundle.js +3 -0
- data/node_modules/swagger-ui-dist/swagger-ui-es-bundle.js.map +1 -0
- data/node_modules/swagger-ui-dist/swagger-ui-standalone-preset.js +3 -0
- data/node_modules/swagger-ui-dist/swagger-ui-standalone-preset.js.map +1 -0
- data/node_modules/swagger-ui-dist/swagger-ui.css +4 -0
- data/node_modules/swagger-ui-dist/swagger-ui.css.map +1 -0
- data/node_modules/swagger-ui-dist/swagger-ui.js +3 -0
- data/node_modules/swagger-ui-dist/swagger-ui.js.map +1 -0
- metadata +138 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: d4a646e7055fce5421d22524a1ae63a497f0de57b5a6abee5f62d3f587549a9b
|
|
4
|
+
data.tar.gz: 4ae62373d7474ac8d4e0703abb6182a5eebf5154457f9ead498f19c957c4f7e2
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: d3465c939a407741f3b6a9930df388372c99c05b297e324543f6cf0ae976bd922083f2b0b0179f01634629d6c06eaed45a2386a7ba605599311518707cf98fcd
|
|
7
|
+
data.tar.gz: 76a50661478751d0896a300546663193d44c0fce9b230816bed10012c92ab2e2097a2a6d8e0e8402efe4eb127d9d5c449884827ca24e80eac31dc8a165451d77
|
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,13 @@
|
|
|
1
|
+
require 'rails/generators'
|
|
2
|
+
|
|
3
|
+
module Rswag
|
|
4
|
+
module Ui
|
|
5
|
+
class CustomGenerator < Rails::Generators::Base
|
|
6
|
+
source_root File.expand_path('../../../../../../lib/rswag/ui', __FILE__)
|
|
7
|
+
|
|
8
|
+
def add_custom_index
|
|
9
|
+
copy_file('index.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,16 @@
|
|
|
1
|
+
Rswag::Ui.configure do |c|
|
|
2
|
+
|
|
3
|
+
# List the Swagger endpoints that you want to be documented through the
|
|
4
|
+
# swagger-ui. The first parameter is the path (absolute or relative to the UI
|
|
5
|
+
# host) to the corresponding endpoint and the second is a title that will be
|
|
6
|
+
# displayed in the document selector.
|
|
7
|
+
# NOTE: If you're using rspec-api to expose Swagger files
|
|
8
|
+
# (under swagger_root) as JSON or YAML endpoints, then the list below should
|
|
9
|
+
# correspond to the relative paths for those endpoints.
|
|
10
|
+
|
|
11
|
+
c.swagger_endpoint '/api-docs/v1/swagger.yaml', 'API V1 Docs'
|
|
12
|
+
|
|
13
|
+
# Add Basic Auth in case your API is private
|
|
14
|
+
# c.basic_auth_enabled = true
|
|
15
|
+
# c.basic_auth_credentials 'username', 'password'
|
|
16
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rack/auth/basic'
|
|
4
|
+
|
|
5
|
+
module Rswag
|
|
6
|
+
module Ui
|
|
7
|
+
# Extend Rack HTTP Basic Authentication, as per RFC 2617.
|
|
8
|
+
# @api private
|
|
9
|
+
#
|
|
10
|
+
class BasicAuth < ::Rack::Auth::Basic
|
|
11
|
+
def call(env)
|
|
12
|
+
return @app.call(env) unless env_matching_path(env)
|
|
13
|
+
|
|
14
|
+
super(env)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
private
|
|
18
|
+
|
|
19
|
+
def env_matching_path(env)
|
|
20
|
+
path = base_path(env['PATH_INFO'])
|
|
21
|
+
Rswag::Ui.config.config_object[:urls].find do |endpoint|
|
|
22
|
+
base_path(endpoint[:url]) == path
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def base_path(url)
|
|
27
|
+
url.downcase.split('/')[1]
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
require 'ostruct'
|
|
2
|
+
require 'rack'
|
|
3
|
+
|
|
4
|
+
module Rswag
|
|
5
|
+
module Ui
|
|
6
|
+
class Configuration
|
|
7
|
+
attr_reader :template_locations
|
|
8
|
+
attr_accessor :basic_auth_enabled
|
|
9
|
+
attr_accessor :config_object
|
|
10
|
+
attr_accessor :oauth_config_object
|
|
11
|
+
attr_reader :assets_root
|
|
12
|
+
|
|
13
|
+
def initialize
|
|
14
|
+
@template_locations = [
|
|
15
|
+
# preferred override location
|
|
16
|
+
"#{Rack::Directory.new('').root}/swagger/index.erb",
|
|
17
|
+
# backwards compatible override location
|
|
18
|
+
"#{Rack::Directory.new('').root}/app/views/rswag/ui/home/index.html.erb",
|
|
19
|
+
# default location
|
|
20
|
+
File.expand_path('../index.erb', __FILE__)
|
|
21
|
+
]
|
|
22
|
+
@assets_root = File.expand_path('../../../../node_modules/swagger-ui-dist', __FILE__)
|
|
23
|
+
@config_object = {}
|
|
24
|
+
@oauth_config_object = {}
|
|
25
|
+
@basic_auth_enabled = false
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def swagger_endpoint(url, name)
|
|
29
|
+
@config_object[:urls] ||= []
|
|
30
|
+
@config_object[:urls] << { url: url, name: name }
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def basic_auth_credentials(username, password)
|
|
34
|
+
@config_object[:basic_auth] = { username: username, password: password }
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# rubocop:disable Naming/AccessorMethodName
|
|
38
|
+
def get_binding
|
|
39
|
+
binding
|
|
40
|
+
end
|
|
41
|
+
# rubocop:enable Naming/AccessorMethodName
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require 'rswag/ui/middleware'
|
|
2
|
+
require 'rswag/ui/basic_auth'
|
|
3
|
+
|
|
4
|
+
module Rswag
|
|
5
|
+
module Ui
|
|
6
|
+
class Engine < ::Rails::Engine
|
|
7
|
+
isolate_namespace Rswag::Ui
|
|
8
|
+
|
|
9
|
+
initializer 'rswag-ui.initialize' do |app|
|
|
10
|
+
middleware.use Rswag::Ui::Middleware, Rswag::Ui.config
|
|
11
|
+
|
|
12
|
+
if Rswag::Ui.config.basic_auth_enabled
|
|
13
|
+
c = Rswag::Ui.config
|
|
14
|
+
app.middleware.use Rswag::Ui::BasicAuth do |username, password|
|
|
15
|
+
c.config_object[:basic_auth].values == [username, password]
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
rake_tasks do
|
|
21
|
+
load File.expand_path('../../../tasks/rswag-ui_tasks.rake', __FILE__)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
<!-- HTML for static distribution bundle build -->
|
|
2
|
+
<!DOCTYPE html>
|
|
3
|
+
<html lang="en">
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="UTF-8">
|
|
6
|
+
<title>Swagger UI</title>
|
|
7
|
+
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700|Source+Code+Pro:300,600|Titillium+Web:400,600,700" rel="stylesheet">
|
|
8
|
+
<link rel="stylesheet" type="text/css" href="./swagger-ui.css" >
|
|
9
|
+
<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
|
|
10
|
+
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
|
|
11
|
+
<style>
|
|
12
|
+
html
|
|
13
|
+
{
|
|
14
|
+
box-sizing: border-box;
|
|
15
|
+
overflow: -moz-scrollbars-vertical;
|
|
16
|
+
overflow-y: scroll;
|
|
17
|
+
}
|
|
18
|
+
*,
|
|
19
|
+
*:before,
|
|
20
|
+
*:after
|
|
21
|
+
{
|
|
22
|
+
box-sizing: inherit;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
body {
|
|
26
|
+
margin:0;
|
|
27
|
+
background: #fafafa;
|
|
28
|
+
}
|
|
29
|
+
</style>
|
|
30
|
+
</head>
|
|
31
|
+
|
|
32
|
+
<body>
|
|
33
|
+
|
|
34
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="position:absolute;width:0;height:0">
|
|
35
|
+
<defs>
|
|
36
|
+
<symbol viewBox="0 0 20 20" id="unlocked">
|
|
37
|
+
<path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V6h2v-.801C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8z"></path>
|
|
38
|
+
</symbol>
|
|
39
|
+
|
|
40
|
+
<symbol viewBox="0 0 20 20" id="locked">
|
|
41
|
+
<path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8zM12 8H8V5.199C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8z"/>
|
|
42
|
+
</symbol>
|
|
43
|
+
|
|
44
|
+
<symbol viewBox="0 0 20 20" id="close">
|
|
45
|
+
<path d="M14.348 14.849c-.469.469-1.229.469-1.697 0L10 11.819l-2.651 3.029c-.469.469-1.229.469-1.697 0-.469-.469-.469-1.229 0-1.697l2.758-3.15-2.759-3.152c-.469-.469-.469-1.228 0-1.697.469-.469 1.228-.469 1.697 0L10 8.183l2.651-3.031c.469-.469 1.228-.469 1.697 0 .469.469.469 1.229 0 1.697l-2.758 3.152 2.758 3.15c.469.469.469 1.229 0 1.698z"/>
|
|
46
|
+
</symbol>
|
|
47
|
+
|
|
48
|
+
<symbol viewBox="0 0 20 20" id="large-arrow">
|
|
49
|
+
<path d="M13.25 10L6.109 2.58c-.268-.27-.268-.707 0-.979.268-.27.701-.27.969 0l7.83 7.908c.268.271.268.709 0 .979l-7.83 7.908c-.268.271-.701.27-.969 0-.268-.269-.268-.707 0-.979L13.25 10z"/>
|
|
50
|
+
</symbol>
|
|
51
|
+
|
|
52
|
+
<symbol viewBox="0 0 20 20" id="large-arrow-down">
|
|
53
|
+
<path d="M17.418 6.109c.272-.268.709-.268.979 0s.271.701 0 .969l-7.908 7.83c-.27.268-.707.268-.979 0l-7.908-7.83c-.27-.268-.27-.701 0-.969.271-.268.709-.268.979 0L10 13.25l7.418-7.141z"/>
|
|
54
|
+
</symbol>
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
<symbol viewBox="0 0 24 24" id="jump-to">
|
|
58
|
+
<path d="M19 7v4H5.83l3.58-3.59L8 6l-6 6 6 6 1.41-1.41L5.83 13H21V7z"/>
|
|
59
|
+
</symbol>
|
|
60
|
+
|
|
61
|
+
<symbol viewBox="0 0 24 24" id="expand">
|
|
62
|
+
<path d="M10 18h4v-2h-4v2zM3 6v2h18V6H3zm3 7h12v-2H6v2z"/>
|
|
63
|
+
</symbol>
|
|
64
|
+
|
|
65
|
+
</defs>
|
|
66
|
+
</svg>
|
|
67
|
+
|
|
68
|
+
<div id="swagger-ui"></div>
|
|
69
|
+
|
|
70
|
+
<!-- Workaround for https://github.com/swagger-api/swagger-editor/issues/1371 -->
|
|
71
|
+
<script>
|
|
72
|
+
if (window.navigator.userAgent.indexOf("Edge") > -1) {
|
|
73
|
+
console.log("Removing native Edge fetch in favor of swagger-ui's polyfill")
|
|
74
|
+
window.fetch = undefined;
|
|
75
|
+
}
|
|
76
|
+
</script>
|
|
77
|
+
|
|
78
|
+
<script src="./swagger-ui-bundle.js"> </script>
|
|
79
|
+
<script src="./swagger-ui-standalone-preset.js"> </script>
|
|
80
|
+
<script>
|
|
81
|
+
window.onload = function () {
|
|
82
|
+
var configObject = JSON.parse('<%= config_object.to_json %>');
|
|
83
|
+
var oauthConfigObject = JSON.parse('<%= oauth_config_object.to_json %>');
|
|
84
|
+
|
|
85
|
+
// Apply mandatory parameters
|
|
86
|
+
configObject.dom_id = "#swagger-ui";
|
|
87
|
+
configObject.presets = [SwaggerUIBundle.presets.apis, SwaggerUIStandalonePreset];
|
|
88
|
+
configObject.layout = "StandaloneLayout";
|
|
89
|
+
|
|
90
|
+
// If oauth2RedirectUrl isn't specified, use the built-in default
|
|
91
|
+
if (!configObject.hasOwnProperty("oauth2RedirectUrl"))
|
|
92
|
+
configObject.oauth2RedirectUrl = window.location.href.replace("index.html", "oauth2-redirect.html");
|
|
93
|
+
|
|
94
|
+
// Build a system
|
|
95
|
+
const ui = SwaggerUIBundle(configObject);
|
|
96
|
+
|
|
97
|
+
// Apply OAuth config
|
|
98
|
+
ui.initOAuth(oauthConfigObject);
|
|
99
|
+
}
|
|
100
|
+
</script>
|
|
101
|
+
</body>
|
|
102
|
+
|
|
103
|
+
</html>
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
module Rswag
|
|
2
|
+
module Ui
|
|
3
|
+
class Middleware < Rack::Static
|
|
4
|
+
|
|
5
|
+
def initialize(app, config)
|
|
6
|
+
@config = config
|
|
7
|
+
super(app, urls: [ '' ], root: config.assets_root )
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def call(env)
|
|
11
|
+
if base_path?(env)
|
|
12
|
+
redirect_uri = env['SCRIPT_NAME'].chomp('/') + '/index.html'
|
|
13
|
+
return [ 301, { 'Location' => redirect_uri }, [ ] ]
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
if index_path?(env)
|
|
17
|
+
return [ 200, { 'Content-Type' => 'text/html', 'Content-Security-Policy' => csp }, [ render_template ] ]
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
super
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
def base_path?(env)
|
|
26
|
+
env['REQUEST_METHOD'] == "GET" && env['PATH_INFO'] == "/"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def index_path?(env)
|
|
30
|
+
env['REQUEST_METHOD'] == "GET" && env['PATH_INFO'] == "/index.html"
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def render_template
|
|
34
|
+
file = File.new(template_filename)
|
|
35
|
+
template = ERB.new(file.read)
|
|
36
|
+
template.result(@config.get_binding)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def template_filename
|
|
40
|
+
@config.template_locations.find { |filename| File.exist?(filename) }
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def csp
|
|
44
|
+
<<-POLICY.gsub "\n", ' '
|
|
45
|
+
default-src 'self';
|
|
46
|
+
img-src 'self' data:;
|
|
47
|
+
font-src 'self' https://fonts.gstatic.com;
|
|
48
|
+
style-src 'self' 'unsafe-inline' https://fonts.googleapis.com;
|
|
49
|
+
script-src 'self' 'unsafe-inline';
|
|
50
|
+
POLICY
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
data/lib/rswag/ui.rb
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
namespace :rswag do
|
|
2
|
+
namespace :ui do
|
|
3
|
+
|
|
4
|
+
desc 'TODO'
|
|
5
|
+
task :copy_assets, [ :dest ] do |t, args|
|
|
6
|
+
dest = args[:dest]
|
|
7
|
+
FileUtils.rm_r(dest, force: true)
|
|
8
|
+
FileUtils.mkdir_p(dest)
|
|
9
|
+
FileUtils.cp_r(Dir.glob("#{Rswag::Ui.config.assets_root}/{*.js,*.png,*.css}"), dest)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Swagger UI Dist
|
|
2
|
+
[](http://badge.fury.io/js/swagger-ui-dist)
|
|
3
|
+
|
|
4
|
+
# API
|
|
5
|
+
|
|
6
|
+
This module, `swagger-ui-dist`, exposes Swagger-UI's entire dist folder as a dependency-free npm module.
|
|
7
|
+
Use `swagger-ui` instead, if you'd like to have npm install dependencies for you.
|
|
8
|
+
|
|
9
|
+
`SwaggerUIBundle` and `SwaggerUIStandalonePreset` can be imported:
|
|
10
|
+
```javascript
|
|
11
|
+
import { SwaggerUIBundle, SwaggerUIStandalonePreset } from "swagger-ui-dist"
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
To get an absolute path to this directory for static file serving, use the exported `getAbsoluteFSPath` method:
|
|
15
|
+
|
|
16
|
+
```javascript
|
|
17
|
+
const swaggerUiAssetPath = require("swagger-ui-dist").getAbsoluteFSPath()
|
|
18
|
+
|
|
19
|
+
// then instantiate server that serves files from the swaggerUiAssetPath
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
For anything else, check the [Swagger-UI](https://github.com/swagger-api/swagger-ui) repository.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* getAbsoluteFSPath
|
|
3
|
+
* @return {string} When run in NodeJS env, returns the absolute path to the current directory
|
|
4
|
+
* When run outside of NodeJS, will return an error message
|
|
5
|
+
*/
|
|
6
|
+
const getAbsoluteFSPath = function () {
|
|
7
|
+
// detect whether we are running in a browser or nodejs
|
|
8
|
+
if (typeof module !== "undefined" && module.exports) {
|
|
9
|
+
return require("path").resolve(__dirname)
|
|
10
|
+
}
|
|
11
|
+
throw new Error('getAbsoluteFSPath can only be called within a Nodejs environment');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
module.exports = getAbsoluteFSPath
|
|
Binary file
|
|
Binary file
|