rswagger-ui 2.0.6
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/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 +10 -0
- data/lib/rswag/ui/configuration.rb +35 -0
- data/lib/rswag/ui/engine.rb +17 -0
- data/lib/rswag/ui/index.erb +103 -0
- data/lib/rswag/ui/middleware.rb +44 -0
- data/lib/rswag/ui.rb +14 -0
- data/lib/tasks/rswag-ui_tasks.rake +12 -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 +67 -0
- data/node_modules/swagger-ui-dist/package.json +74 -0
- data/node_modules/swagger-ui-dist/swagger-ui-bundle.js +110 -0
- data/node_modules/swagger-ui-dist/swagger-ui-bundle.js.map +1 -0
- data/node_modules/swagger-ui-dist/swagger-ui-standalone-preset.js +14 -0
- data/node_modules/swagger-ui-dist/swagger-ui-standalone-preset.js.map +1 -0
- data/node_modules/swagger-ui-dist/swagger-ui.css +3 -0
- data/node_modules/swagger-ui-dist/swagger-ui.css.map +1 -0
- data/node_modules/swagger-ui-dist/swagger-ui.js +9 -0
- data/node_modules/swagger-ui-dist/swagger-ui.js.map +1 -0
- metadata +102 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0d8d2bb9413b9671ddeebe3ccbb7d4d9cda414e08a4db60d6e9f1f68687da056
|
4
|
+
data.tar.gz: 8c4210e9c91a671a177eb80279f55734aac61026fb1d20e02ce2dd76d6550e8f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 44f532a36e9ecf36b34ead36c3f2a02e22341d985feb6c2ed1dc9ef44cc27ffc69417ff634f1993730a23d0e04558a17f7a5fd4cd25f9d2435c06a359f103c3c
|
7
|
+
data.tar.gz: cdccf0db5fd7c8ebe70dd47d95f305fc8269be49e166d0497ed1023186440dc07fcc93946afefeb067212db563c3a93adf80c65f8878218ae7f9c1a9237d261d
|
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,10 @@
|
|
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
|
+
|
9
|
+
c.swagger_endpoint '/api-docs/v1/swagger.json', 'API V1 Docs'
|
10
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
|
3
|
+
module Rswag
|
4
|
+
module Ui
|
5
|
+
class Configuration
|
6
|
+
attr_reader :template_locations
|
7
|
+
attr_accessor :config_object
|
8
|
+
attr_accessor :oauth_config_object
|
9
|
+
attr_reader :assets_root
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@template_locations = [
|
13
|
+
# preffered override location
|
14
|
+
"#{Rack::Directory.new('').root}/swagger/index.erb",
|
15
|
+
# backwards compatible override location
|
16
|
+
"#{Rack::Directory.new('').root}/app/views/rswag/ui/home/index.html.erb",
|
17
|
+
# default location
|
18
|
+
File.expand_path('../index.erb', __FILE__)
|
19
|
+
]
|
20
|
+
@assets_root = File.expand_path('../../../../node_modules/swagger-ui-dist', __FILE__)
|
21
|
+
@config_object = {}
|
22
|
+
@oauth_config_object = {}
|
23
|
+
end
|
24
|
+
|
25
|
+
def swagger_endpoint(url, name)
|
26
|
+
@config_object[:urls] ||= []
|
27
|
+
@config_object[:urls] << { url: url, name: name }
|
28
|
+
end
|
29
|
+
|
30
|
+
def get_binding
|
31
|
+
binding
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rswag/ui/middleware'
|
2
|
+
|
3
|
+
module Rswag
|
4
|
+
module Ui
|
5
|
+
class Engine < ::Rails::Engine
|
6
|
+
isolate_namespace Rswag::Ui
|
7
|
+
|
8
|
+
initializer 'rswag-ui.initialize' do |app|
|
9
|
+
middleware.use Rswag::Ui::Middleware, Rswag::Ui.config
|
10
|
+
end
|
11
|
+
|
12
|
+
rake_tasks do
|
13
|
+
load File.expand_path('../../../tasks/rswag-ui_tasks.rake', __FILE__)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
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,44 @@
|
|
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' }, [ 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.exists?(filename) }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
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,22 @@
|
|
1
|
+
# Swagger UI Dist
|
2
|
+
[![NPM version](https://badge.fury.io/js/swagger-ui-dist.svg)](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
|
@@ -0,0 +1,60 @@
|
|
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 rel="stylesheet" type="text/css" href="./swagger-ui.css" >
|
8
|
+
<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
|
9
|
+
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
|
10
|
+
<style>
|
11
|
+
html
|
12
|
+
{
|
13
|
+
box-sizing: border-box;
|
14
|
+
overflow: -moz-scrollbars-vertical;
|
15
|
+
overflow-y: scroll;
|
16
|
+
}
|
17
|
+
|
18
|
+
*,
|
19
|
+
*:before,
|
20
|
+
*:after
|
21
|
+
{
|
22
|
+
box-sizing: inherit;
|
23
|
+
}
|
24
|
+
|
25
|
+
body
|
26
|
+
{
|
27
|
+
margin:0;
|
28
|
+
background: #fafafa;
|
29
|
+
}
|
30
|
+
</style>
|
31
|
+
</head>
|
32
|
+
|
33
|
+
<body>
|
34
|
+
<div id="swagger-ui"></div>
|
35
|
+
|
36
|
+
<script src="./swagger-ui-bundle.js"> </script>
|
37
|
+
<script src="./swagger-ui-standalone-preset.js"> </script>
|
38
|
+
<script>
|
39
|
+
window.onload = function() {
|
40
|
+
|
41
|
+
// Build a system
|
42
|
+
const ui = SwaggerUIBundle({
|
43
|
+
url: "https://petstore.swagger.io/v2/swagger.json",
|
44
|
+
dom_id: '#swagger-ui',
|
45
|
+
deepLinking: true,
|
46
|
+
presets: [
|
47
|
+
SwaggerUIBundle.presets.apis,
|
48
|
+
SwaggerUIStandalonePreset
|
49
|
+
],
|
50
|
+
plugins: [
|
51
|
+
SwaggerUIBundle.plugins.DownloadUrl
|
52
|
+
],
|
53
|
+
layout: "StandaloneLayout"
|
54
|
+
})
|
55
|
+
|
56
|
+
window.ui = ui
|
57
|
+
}
|
58
|
+
</script>
|
59
|
+
</body>
|
60
|
+
</html>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
try {
|
2
|
+
module.exports.SwaggerUIBundle = require("./swagger-ui-bundle.js")
|
3
|
+
module.exports.SwaggerUIStandalonePreset = require("./swagger-ui-standalone-preset.js")
|
4
|
+
} catch(e) {
|
5
|
+
// swallow the error if there's a problem loading the assets.
|
6
|
+
// allows this module to support providing the assets for browserish contexts,
|
7
|
+
// without exploding in a Node context.
|
8
|
+
//
|
9
|
+
// see https://github.com/swagger-api/swagger-ui/issues/3291#issuecomment-311195388
|
10
|
+
// for more information.
|
11
|
+
}
|
12
|
+
|
13
|
+
// `absolutePath` and `getAbsoluteFSPath` are both here because at one point,
|
14
|
+
// we documented having one and actually implemented the other.
|
15
|
+
// They were both retained so we don't break anyone's code.
|
16
|
+
module.exports.absolutePath = require("./absolute-path.js")
|
17
|
+
module.exports.getAbsoluteFSPath = require("./absolute-path.js")
|
@@ -0,0 +1,67 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html lang="en-US">
|
3
|
+
<body onload="run()">
|
4
|
+
</body>
|
5
|
+
</html>
|
6
|
+
<script>
|
7
|
+
'use strict';
|
8
|
+
function run () {
|
9
|
+
var oauth2 = window.opener.swaggerUIRedirectOauth2;
|
10
|
+
var sentState = oauth2.state;
|
11
|
+
var redirectUrl = oauth2.redirectUrl;
|
12
|
+
var isValid, qp, arr;
|
13
|
+
|
14
|
+
if (/code|token|error/.test(window.location.hash)) {
|
15
|
+
qp = window.location.hash.substring(1);
|
16
|
+
} else {
|
17
|
+
qp = location.search.substring(1);
|
18
|
+
}
|
19
|
+
|
20
|
+
arr = qp.split("&")
|
21
|
+
arr.forEach(function (v,i,_arr) { _arr[i] = '"' + v.replace('=', '":"') + '"';})
|
22
|
+
qp = qp ? JSON.parse('{' + arr.join() + '}',
|
23
|
+
function (key, value) {
|
24
|
+
return key === "" ? value : decodeURIComponent(value)
|
25
|
+
}
|
26
|
+
) : {}
|
27
|
+
|
28
|
+
isValid = qp.state === sentState
|
29
|
+
|
30
|
+
if ((
|
31
|
+
oauth2.auth.schema.get("flow") === "accessCode"||
|
32
|
+
oauth2.auth.schema.get("flow") === "authorizationCode"
|
33
|
+
) && !oauth2.auth.code) {
|
34
|
+
if (!isValid) {
|
35
|
+
oauth2.errCb({
|
36
|
+
authId: oauth2.auth.name,
|
37
|
+
source: "auth",
|
38
|
+
level: "warning",
|
39
|
+
message: "Authorization may be unsafe, passed state was changed in server Passed state wasn't returned from auth server"
|
40
|
+
});
|
41
|
+
}
|
42
|
+
|
43
|
+
if (qp.code) {
|
44
|
+
delete oauth2.state;
|
45
|
+
oauth2.auth.code = qp.code;
|
46
|
+
oauth2.callback({auth: oauth2.auth, redirectUrl: redirectUrl});
|
47
|
+
} else {
|
48
|
+
let oauthErrorMsg
|
49
|
+
if (qp.error) {
|
50
|
+
oauthErrorMsg = "["+qp.error+"]: " +
|
51
|
+
(qp.error_description ? qp.error_description+ ". " : "no accessCode received from the server. ") +
|
52
|
+
(qp.error_uri ? "More info: "+qp.error_uri : "");
|
53
|
+
}
|
54
|
+
|
55
|
+
oauth2.errCb({
|
56
|
+
authId: oauth2.auth.name,
|
57
|
+
source: "auth",
|
58
|
+
level: "error",
|
59
|
+
message: oauthErrorMsg || "[Authorization failed]: no accessCode received from the server"
|
60
|
+
});
|
61
|
+
}
|
62
|
+
} else {
|
63
|
+
oauth2.callback({auth: oauth2.auth, token: qp, isValid: isValid, redirectUrl: redirectUrl});
|
64
|
+
}
|
65
|
+
window.close();
|
66
|
+
}
|
67
|
+
</script>
|
@@ -0,0 +1,74 @@
|
|
1
|
+
{
|
2
|
+
"_args": [
|
3
|
+
[
|
4
|
+
"swagger-ui-dist@3.17.3",
|
5
|
+
"/Users/user/projects/rswag/rswag-ui"
|
6
|
+
]
|
7
|
+
],
|
8
|
+
"_from": "swagger-ui-dist@3.17.3",
|
9
|
+
"_id": "swagger-ui-dist@3.17.3",
|
10
|
+
"_inBundle": false,
|
11
|
+
"_integrity": "sha1-37lkCMzEZ3UVX3NpGQxdSyAW/lw=",
|
12
|
+
"_location": "/swagger-ui-dist",
|
13
|
+
"_phantomChildren": {},
|
14
|
+
"_requested": {
|
15
|
+
"type": "version",
|
16
|
+
"registry": true,
|
17
|
+
"raw": "swagger-ui-dist@3.17.3",
|
18
|
+
"name": "swagger-ui-dist",
|
19
|
+
"escapedName": "swagger-ui-dist",
|
20
|
+
"rawSpec": "3.17.3",
|
21
|
+
"saveSpec": null,
|
22
|
+
"fetchSpec": "3.17.3"
|
23
|
+
},
|
24
|
+
"_requiredBy": [
|
25
|
+
"/"
|
26
|
+
],
|
27
|
+
"_resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-3.17.3.tgz",
|
28
|
+
"_spec": "3.17.3",
|
29
|
+
"_where": "/Users/user/projects/rswag/rswag-ui",
|
30
|
+
"bugs": {
|
31
|
+
"url": "https://github.com/swagger-api/swagger-ui/issues"
|
32
|
+
},
|
33
|
+
"contributors": [
|
34
|
+
{
|
35
|
+
"url": "in alphabetical order"
|
36
|
+
},
|
37
|
+
{
|
38
|
+
"name": "Anna Bodnia",
|
39
|
+
"email": "anna.bodnia@gmail.com"
|
40
|
+
},
|
41
|
+
{
|
42
|
+
"name": "Buu Nguyen",
|
43
|
+
"email": "buunguyen@gmail.com"
|
44
|
+
},
|
45
|
+
{
|
46
|
+
"name": "Josh Ponelat",
|
47
|
+
"email": "jponelat@gmail.com"
|
48
|
+
},
|
49
|
+
{
|
50
|
+
"name": "Kyle Shockey",
|
51
|
+
"email": "kyleshockey1@gmail.com"
|
52
|
+
},
|
53
|
+
{
|
54
|
+
"name": "Robert Barnwell",
|
55
|
+
"email": "robert@robertismy.name"
|
56
|
+
},
|
57
|
+
{
|
58
|
+
"name": "Sahar Jafari",
|
59
|
+
"email": "shr.jafari@gmail.com"
|
60
|
+
}
|
61
|
+
],
|
62
|
+
"dependencies": {},
|
63
|
+
"description": "[![NPM version](https://badge.fury.io/js/swagger-ui-dist.svg)](http://badge.fury.io/js/swagger-ui-dist)",
|
64
|
+
"devDependencies": {},
|
65
|
+
"homepage": "https://github.com/swagger-api/swagger-ui#readme",
|
66
|
+
"license": "Apache-2.0",
|
67
|
+
"main": "index.js",
|
68
|
+
"name": "swagger-ui-dist",
|
69
|
+
"repository": {
|
70
|
+
"type": "git",
|
71
|
+
"url": "git+ssh://git@github.com/swagger-api/swagger-ui.git"
|
72
|
+
},
|
73
|
+
"version": "3.17.3"
|
74
|
+
}
|