swagger_ui_engine_rails7 1.2.1
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/CHANGELOG.md +65 -0
- data/MIT-LICENSE +20 -0
- data/Rakefile +28 -0
- data/app/assets/fonts/swagger_ui_engine/DroidSans-Bold.ttf +0 -0
- data/app/assets/fonts/swagger_ui_engine/DroidSans.ttf +0 -0
- data/app/assets/images/swagger_ui_engine/collapse.gif +0 -0
- data/app/assets/images/swagger_ui_engine/expand.gif +0 -0
- data/app/assets/images/swagger_ui_engine/explorer_icons.png +0 -0
- data/app/assets/images/swagger_ui_engine/favicon-16x16.png +0 -0
- data/app/assets/images/swagger_ui_engine/favicon-32x32.png +0 -0
- data/app/assets/images/swagger_ui_engine/favicon.ico +0 -0
- data/app/assets/images/swagger_ui_engine/logo_small.png +0 -0
- data/app/assets/images/swagger_ui_engine/pet_store_api.png +0 -0
- data/app/assets/images/swagger_ui_engine/throbber.gif +0 -0
- data/app/assets/images/swagger_ui_engine/wordnik_api.png +0 -0
- data/app/assets/javascripts/swagger_ui_engine/application.js +14 -0
- data/app/assets/javascripts/swagger_ui_engine/lang/ca.js +55 -0
- data/app/assets/javascripts/swagger_ui_engine/lang/de.js +58 -0
- data/app/assets/javascripts/swagger_ui_engine/lang/el.js +58 -0
- data/app/assets/javascripts/swagger_ui_engine/lang/en.js +58 -0
- data/app/assets/javascripts/swagger_ui_engine/lang/es.js +55 -0
- data/app/assets/javascripts/swagger_ui_engine/lang/fr.js +56 -0
- data/app/assets/javascripts/swagger_ui_engine/lang/geo.js +58 -0
- data/app/assets/javascripts/swagger_ui_engine/lang/it.js +54 -0
- data/app/assets/javascripts/swagger_ui_engine/lang/ja.js +58 -0
- data/app/assets/javascripts/swagger_ui_engine/lang/ko-kr.js +55 -0
- data/app/assets/javascripts/swagger_ui_engine/lang/pl.js +55 -0
- data/app/assets/javascripts/swagger_ui_engine/lang/pt.js +55 -0
- data/app/assets/javascripts/swagger_ui_engine/lang/ru.js +58 -0
- data/app/assets/javascripts/swagger_ui_engine/lang/tr.js +55 -0
- data/app/assets/javascripts/swagger_ui_engine/lang/translator.js +39 -0
- data/app/assets/javascripts/swagger_ui_engine/lang/zh-cn.js +58 -0
- data/app/assets/javascripts/swagger_ui_engine/lib/backbone-min.js +1 -0
- data/app/assets/javascripts/swagger_ui_engine/lib/es5-shim.js +1 -0
- data/app/assets/javascripts/swagger_ui_engine/lib/handlebars-4.0.5.js +3 -0
- data/app/assets/javascripts/swagger_ui_engine/lib/highlight.9.1.0.pack.js +1 -0
- data/app/assets/javascripts/swagger_ui_engine/lib/highlight.9.1.0.pack_extended.js +1 -0
- data/app/assets/javascripts/swagger_ui_engine/lib/jquery-1.8.0.min.js +3 -0
- data/app/assets/javascripts/swagger_ui_engine/lib/jquery.ba-bbq.min.js +1 -0
- data/app/assets/javascripts/swagger_ui_engine/lib/jquery.slideto.min.js +1 -0
- data/app/assets/javascripts/swagger_ui_engine/lib/jquery.wiggle.min.js +1 -0
- data/app/assets/javascripts/swagger_ui_engine/lib/js-yaml.min.js +2 -0
- data/app/assets/javascripts/swagger_ui_engine/lib/jsoneditor.min.js +5 -0
- data/app/assets/javascripts/swagger_ui_engine/lib/lodash.min.js +2 -0
- data/app/assets/javascripts/swagger_ui_engine/lib/marked.js +1 -0
- data/app/assets/javascripts/swagger_ui_engine/lib/object-assign-pollyfill.js +1 -0
- data/app/assets/javascripts/swagger_ui_engine/lib/sanitize-html.min.js +4 -0
- data/app/assets/javascripts/swagger_ui_engine/lib/swagger-oauth.js +1 -0
- data/app/assets/javascripts/swagger_ui_engine/swagger-ui.js +25344 -0
- data/app/assets/javascripts/swagger_ui_engine/swagger-ui.min.js +15 -0
- data/app/assets/javascripts/swagger_ui_engine/swagger.json +18 -0
- data/app/assets/stylesheets/swagger_ui_engine/application.css +6 -0
- data/app/assets/stylesheets/swagger_ui_engine/custom.css +7 -0
- data/app/assets/stylesheets/swagger_ui_engine/lib/print.css.erb +1377 -0
- data/app/assets/stylesheets/swagger_ui_engine/lib/reset.css +1 -0
- data/app/assets/stylesheets/swagger_ui_engine/lib/screen.css.erb +1504 -0
- data/app/assets/stylesheets/swagger_ui_engine/lib/style.css +1 -0
- data/app/assets/stylesheets/swagger_ui_engine/lib/typography.css.erb +14 -0
- data/app/assets/stylesheets/swagger_ui_engine/print.css +4 -0
- data/app/controllers/swagger_ui_engine/application_controller.rb +20 -0
- data/app/controllers/swagger_ui_engine/swagger_docs_controller.rb +51 -0
- data/app/helpers/swagger_ui_engine/auth_config_parser.rb +19 -0
- data/app/helpers/swagger_ui_engine/config_parser.rb +26 -0
- data/app/helpers/swagger_ui_engine/oauth_config_parser.rb +12 -0
- data/app/helpers/swagger_ui_engine/translation_helper.rb +16 -0
- data/app/views/swagger_ui_engine/layouts/swagger.html.erb +37 -0
- data/app/views/swagger_ui_engine/swagger_docs/index.html.erb +8 -0
- data/app/views/swagger_ui_engine/swagger_docs/oauth2.html.erb +20 -0
- data/app/views/swagger_ui_engine/swagger_docs/show.html.erb +66 -0
- data/config/routes.rb +12 -0
- data/lib/swagger_ui_engine_rails7/configuration.rb +24 -0
- data/lib/swagger_ui_engine_rails7/defaults.rb +19 -0
- data/lib/swagger_ui_engine_rails7/engine.rb +28 -0
- data/lib/swagger_ui_engine_rails7/version.rb +4 -0
- data/lib/swagger_ui_engine_rails7.rb +20 -0
- metadata +148 -0
@@ -0,0 +1 @@
|
|
1
|
+
.swagger-section #header a#logo{font-size:1.5em;font-weight:700;text-decoration:none;padding:20px 0 20px 40px}#text-head{font-size:80px;font-family:Roboto,sans-serif;color:#fff;float:right;margin-right:20%}.navbar-fixed-top .navbar-brand,.navbar-fixed-top .navbar-nav,.navbar-header{height:auto}.navbar-inverse{background-color:#000;border-color:#000}#navbar-brand{margin-left:20%}.navtext{font-size:10px}.h1,h1{font-size:60px}.navbar-default .navbar-header .navbar-brand{color:#a2dfee}.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading h2 a{color:#393939;font-family:Arvo,serif;font-size:1.5em}.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading h2 a:hover{color:#000}.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading h2{color:#525252;padding-left:0;display:block;clear:none;float:left;font-family:Arvo,serif;font-weight:700}.navbar-default .navbar-collapse,.navbar-default .navbar-form{border-color:#0a0a0a}.container1{width:1500px;margin:auto;margin-top:0;background-repeat:no-repeat;background-position:-40px -20px;margin-bottom:210px}.container-inner{width:1200px;margin:auto;background-color:hsla(192,8%,88%,.75);padding-bottom:40px;padding-top:40px;border-radius:15px}.header-content{padding:0;width:1000px}.title1{font-size:80px;font-family:Vollkorn,serif;color:#404040;text-align:center;padding-top:40px;padding-bottom:100px}#icon{margin-top:-18px}.subtext{font-size:25px;font-style:italic;color:#08b;text-align:right;padding-right:250px}.bg-primary{background-color:#00468b}.navbar-default .nav>li>a,.navbar-default .nav>li>a:focus,.navbar-default .nav>li>a:focus:hover,.navbar-default .nav>li>a:hover{color:#08b}.text-faded{font-size:25px;font-family:Vollkorn,serif}.section-heading{font-family:Vollkorn,serif;font-size:45px;padding-bottom:10px}hr{border-color:#00468b;padding-bottom:10px}.description{margin-top:20px;padding-bottom:200px}.description li{font-family:Vollkorn,serif;font-size:25px;color:#525252;margin-left:28%;padding-top:5px}.gap{margin-top:200px}.troubleshootingtext{color:hsla(0,0%,100%,.7);padding-left:30%}.troubleshootingtext li{list-style-type:circle;font-size:25px;padding-bottom:5px}.overlay{position:absolute;top:0;left:0;width:100%;height:100%;z-index:1}.block.response_body.json:hover{cursor:pointer}.backdrop{color:blue}#myModal{height:100%}.modal-backdrop{bottom:0;position:fixed}.curl{padding:10px;font-family:Anonymous Pro,Menlo,Consolas,Bitstream Vera Sans Mono,Courier New,monospace;font-size:.9em;max-height:400px;margin-top:5px;overflow-y:auto;background-color:#fcf6db;border:1px solid #e5e0c6;border-radius:4px}.curl_title{font-size:1.1em;margin:0;padding:15px 0 5px;font-family:Open Sans,Helvetica Neue,Arial,sans-serif;font-weight:500;line-height:1.1}.footer{display:none}.swagger-section .swagger-ui-wrap h2{padding:0}h2{margin:0;margin-bottom:5px}.markdown p,.swagger-section .swagger-ui-wrap .code{font-size:15px;font-family:Arvo,serif}.swagger-section .swagger-ui-wrap b{font-family:Arvo,serif}#signin:hover{cursor:pointer}.dropdown-menu{padding:15px}.navbar-right .dropdown-menu{left:0;right:auto}#signinbutton{width:100%;height:32px;font-size:13px;font-weight:700;color:#08b}.navbar-default .nav>li .details{color:#000;text-transform:none;font-size:15px;font-weight:400;font-family:Open Sans,sans-serif;font-style:italic;line-height:20px;top:-2px}.navbar-default .nav>li .details:hover{color:#000}#signout{width:100%;height:32px;font-size:13px;font-weight:700;color:#08b}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
/* Google Font's Droid Sans */
|
2
|
+
@font-face {
|
3
|
+
font-family: 'Droid Sans';
|
4
|
+
font-style: normal;
|
5
|
+
font-weight: 400;
|
6
|
+
src: local('Droid Sans'), local('DroidSans'), url("<%= asset_path('swagger_ui_engine/DroidSans.ttf') %>") format('truetype');
|
7
|
+
}
|
8
|
+
/* Google Font's Droid Sans Bold */
|
9
|
+
@font-face {
|
10
|
+
font-family: 'Droid Sans';
|
11
|
+
font-style: normal;
|
12
|
+
font-weight: 700;
|
13
|
+
src: local('Droid Sans Bold'), local('DroidSans-Bold'), url("<%= asset_path('swagger_ui_engine/DroidSans-Bold.ttf') %>") format('truetype');
|
14
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module SwaggerUiEngine
|
2
|
+
class ApplicationController < ActionController::Base
|
3
|
+
include SwaggerUiEngine::AuthConfigParser
|
4
|
+
|
5
|
+
protect_from_forgery with: :exception
|
6
|
+
layout false
|
7
|
+
|
8
|
+
before_action :authenticate_admin
|
9
|
+
|
10
|
+
protected
|
11
|
+
|
12
|
+
def authenticate_admin
|
13
|
+
return unless basic_authentication_enabled?
|
14
|
+
|
15
|
+
authenticate_or_request_with_http_basic do |username, password|
|
16
|
+
username == admin_username && password == admin_password
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module SwaggerUiEngine
|
2
|
+
class SwaggerDocsController < SwaggerUiEngine::ApplicationController
|
3
|
+
include SwaggerUiEngine::ConfigParser
|
4
|
+
include SwaggerUiEngine::OauthConfigParser
|
5
|
+
|
6
|
+
helper SwaggerUiEngine::TranslationHelper
|
7
|
+
layout 'swagger_ui_engine/layouts/swagger', except: %w(oauth2)
|
8
|
+
|
9
|
+
before_action :set_configs, :set_oauth_configs
|
10
|
+
|
11
|
+
def oauth2
|
12
|
+
end
|
13
|
+
|
14
|
+
def index
|
15
|
+
# backward compatibility for defining single doc url in strings
|
16
|
+
redirect_to single_swagger_doc_path if single_doc_url?
|
17
|
+
redirect_to swagger_doc_path(@swagger_url.keys.first) if single_doc_url_hash?
|
18
|
+
end
|
19
|
+
|
20
|
+
def show
|
21
|
+
@single_doc_url = single_doc_url? || single_doc_url_hash?
|
22
|
+
@swagger_url = @swagger_url[params[:id].to_sym] unless single_doc_url?
|
23
|
+
end
|
24
|
+
|
25
|
+
def single_doc
|
26
|
+
render 'show'
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def set_configs
|
32
|
+
SwaggerUiEngine::DEFAULTS.keys.each do |key|
|
33
|
+
instance_variable_set("@#{key}", self.send("set_#{key}"))
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def set_oauth_configs
|
38
|
+
SwaggerUiEngine::OAUTH2_DEFAULTS.keys.each do |key|
|
39
|
+
instance_variable_set("@#{key}", self.send("set_#{key}"))
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def single_doc_url?
|
44
|
+
@swagger_url.is_a?(String)
|
45
|
+
end
|
46
|
+
|
47
|
+
def single_doc_url_hash?
|
48
|
+
@swagger_url.is_a?(Hash) && @swagger_url.size.eql?(1)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module SwaggerUiEngine
|
2
|
+
module AuthConfigParser
|
3
|
+
def admin_username
|
4
|
+
configuration.admin_username
|
5
|
+
end
|
6
|
+
|
7
|
+
def admin_password
|
8
|
+
configuration.admin_password
|
9
|
+
end
|
10
|
+
|
11
|
+
def basic_authentication_enabled?
|
12
|
+
admin_username && admin_password
|
13
|
+
end
|
14
|
+
|
15
|
+
def configuration
|
16
|
+
SwaggerUiEngine.configuration
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module SwaggerUiEngine
|
2
|
+
module ConfigParser
|
3
|
+
SwaggerUiEngine::DEFAULTS.each do |default|
|
4
|
+
next if default.first.to_s.eql?('validator_url')
|
5
|
+
|
6
|
+
define_method("set_#{default.first}") do
|
7
|
+
# set_swagger_url set_doc_expansion
|
8
|
+
# set_json_editor set_model_rendering
|
9
|
+
# set_request_headers
|
10
|
+
configuration.send("#{default.first}") || default.last
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def set_validator_url
|
15
|
+
validator_enabled? ? SwaggerUiEngine::DEFAULTS[:validator_url] : 'null'
|
16
|
+
end
|
17
|
+
|
18
|
+
def validator_enabled?
|
19
|
+
configuration.validator_enabled || false
|
20
|
+
end
|
21
|
+
|
22
|
+
def configuration
|
23
|
+
SwaggerUiEngine.configuration
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module SwaggerUiEngine
|
2
|
+
module OauthConfigParser
|
3
|
+
SwaggerUiEngine::OAUTH2_DEFAULTS.each do |default|
|
4
|
+
define_method("set_#{default.first}") do
|
5
|
+
# set_oauth_app_name set_oauth_client_id
|
6
|
+
# set_oauth_client_secret set_oauth_realm
|
7
|
+
# set_oauth_scope_separator set_oauth_query_string_params
|
8
|
+
configuration.send("#{default.first}") || default.last
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module SwaggerUiEngine
|
2
|
+
module TranslationHelper
|
3
|
+
def load_translation_file
|
4
|
+
return unless translator_enabled?
|
5
|
+
javascript_include_tag('swagger_ui_engine/lang/translator', lang_file_path)
|
6
|
+
end
|
7
|
+
|
8
|
+
def lang_file_path
|
9
|
+
"swagger_ui_engine/lang/#{I18n.locale.to_s.downcase}.js"
|
10
|
+
end
|
11
|
+
|
12
|
+
def translator_enabled?
|
13
|
+
SwaggerUiEngine.configuration.translator_enabled
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="UTF-8">
|
5
|
+
<meta http-equiv="x-ua-compatible" content="IE=edge">
|
6
|
+
<title>Swagger UI</title>
|
7
|
+
<link rel="icon" type="image/png" href="<%= image_path('swagger_ui_engine/favicon-32x32.png') %>" sizes="32x32" />
|
8
|
+
<link rel="icon" type="image/png" href="<%= image_path('swagger_ui_engine/favicon-16x16.png') %>" sizes="16x16" />
|
9
|
+
|
10
|
+
<%= stylesheet_link_tag "swagger_ui_engine/application", media: "screen" %>
|
11
|
+
<%= stylesheet_link_tag "swagger_ui_engine/print", media: "print" %>
|
12
|
+
|
13
|
+
<%= javascript_include_tag "swagger_ui_engine/application" %>
|
14
|
+
<%= csrf_meta_tags %>
|
15
|
+
<%= yield :head %>
|
16
|
+
</head>
|
17
|
+
|
18
|
+
<body class="swagger-section">
|
19
|
+
<div id='header'>
|
20
|
+
<div class="swagger-ui-wrap">
|
21
|
+
<a id="logo" href="http://swagger.io"><img class="logo__img" alt="swagger" height="30" width="30" src="<%= image_path('swagger_ui_engine/logo_small.png') %>" /><span class="logo__title">swagger</span></a>
|
22
|
+
|
23
|
+
<form id='api_selector'>
|
24
|
+
<div class='input'><input placeholder="http://example.com/api" id="input_baseUrl" name="baseUrl" type="text"/></div>
|
25
|
+
<div id='auth_container'></div>
|
26
|
+
<div class='input'><a id="explore" class="header__btn" href="#" data-sw-translate>Explore</a></div>
|
27
|
+
</form>
|
28
|
+
</div>
|
29
|
+
|
30
|
+
</div>
|
31
|
+
|
32
|
+
<div id="message-bar" class="swagger-ui-wrap" data-sw-translate> </div>
|
33
|
+
<div id="swagger-ui-container" class="swagger-ui-wrap">
|
34
|
+
<%= yield %>
|
35
|
+
</div>
|
36
|
+
</body>
|
37
|
+
</html>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<script>
|
2
|
+
var qp = null;
|
3
|
+
if(/code|token|error/.test(window.location.hash)) {
|
4
|
+
qp = location.hash.substring(1);
|
5
|
+
}
|
6
|
+
else {
|
7
|
+
qp = location.search.substring(1);
|
8
|
+
}
|
9
|
+
qp = qp ? JSON.parse('{"' + qp.replace(/&/g, '","').replace(/=/g,'":"') + '"}',
|
10
|
+
function(key, value) {
|
11
|
+
return key===""?value:decodeURIComponent(value) }
|
12
|
+
):{}
|
13
|
+
|
14
|
+
if (window.opener.swaggerUiAuth.tokenUrl)
|
15
|
+
window.opener.processOAuthCode(qp);
|
16
|
+
else
|
17
|
+
window.opener.onOAuthComplete(qp);
|
18
|
+
|
19
|
+
window.close();
|
20
|
+
</script>
|
@@ -0,0 +1,66 @@
|
|
1
|
+
<% content_for(:head) do %>
|
2
|
+
<script type="text/javascript">
|
3
|
+
$(function () {
|
4
|
+
var url = window.location.search.match(/url=([^&]+)/);
|
5
|
+
if (url && url.length > 1) {
|
6
|
+
url = decodeURIComponent(url[1]);
|
7
|
+
} else {
|
8
|
+
url = "<%= @swagger_url %>";
|
9
|
+
}
|
10
|
+
|
11
|
+
hljs.configure({
|
12
|
+
highlightSizeThreshold: 5000
|
13
|
+
});
|
14
|
+
|
15
|
+
// Pre load translate...
|
16
|
+
if(window.SwaggerTranslator) {
|
17
|
+
window.SwaggerTranslator.translate();
|
18
|
+
}
|
19
|
+
window.swaggerUi = new SwaggerUi({
|
20
|
+
url: url,
|
21
|
+
validatorUrl: "<%= @validator_url %>",
|
22
|
+
oauth2RedirectUrl: "<%= oauth2_swagger_docs_url %>",
|
23
|
+
dom_id: "swagger-ui-container",
|
24
|
+
supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
|
25
|
+
onComplete: function(swaggerApi, swaggerUi){
|
26
|
+
if(typeof initOAuth == "function") {
|
27
|
+
initOAuth({
|
28
|
+
clientId: "<%= @oauth_client_id %>",
|
29
|
+
clientSecret: "<%= @oauth_client_secret %>",
|
30
|
+
realm: "<%= @oauth_realm %>",
|
31
|
+
appName: "<%= @oauth_app_name %>",
|
32
|
+
scopeSeparator: "<%= @oauth_scope_separator %>",
|
33
|
+
additionalQueryStringParams: "<%= @oauth_query_string_params %>"
|
34
|
+
});
|
35
|
+
}
|
36
|
+
|
37
|
+
if(window.SwaggerTranslator) {
|
38
|
+
window.SwaggerTranslator.translate();
|
39
|
+
}
|
40
|
+
},
|
41
|
+
onFailure: function(data) {
|
42
|
+
log("Unable to Load SwaggerUI");
|
43
|
+
},
|
44
|
+
docExpansion: "<%= @doc_expansion %>",
|
45
|
+
jsonEditor: "<%= @json_editor %>",
|
46
|
+
defaultModelRendering: "<%= @model_rendering %>",
|
47
|
+
showRequestHeaders: "<%= @request_headers %>",
|
48
|
+
showOperationIds: false
|
49
|
+
});
|
50
|
+
|
51
|
+
window.swaggerUi.load();
|
52
|
+
|
53
|
+
function log() {
|
54
|
+
if ('console' in window) {
|
55
|
+
console.log.apply(console, arguments);
|
56
|
+
}
|
57
|
+
}
|
58
|
+
});
|
59
|
+
</script>
|
60
|
+
<% end %>
|
61
|
+
|
62
|
+
<% unless @single_doc_url %>
|
63
|
+
<div class="swagger-ui-wrap">
|
64
|
+
<a href="<%= swagger_docs_path %>" class="swagger-return-link" data-sw-translate> Back to the list </a>
|
65
|
+
</div>
|
66
|
+
<% end %>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
SwaggerUiEngineRails7::Engine.routes.draw do
|
2
|
+
scope format: false do
|
3
|
+
resources :swagger_docs, only: [:index, :show] do
|
4
|
+
collection do
|
5
|
+
get 'oauth2', to: 'swagger_docs#oauth2', format: false
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
get 'single_swagger_doc', to: 'swagger_docs#single_doc', format: false
|
10
|
+
root to: 'swagger_docs#index'
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module SwaggerUiEngineRails7
|
2
|
+
class Configuration
|
3
|
+
# Configurable options
|
4
|
+
OPTIONS = %i(
|
5
|
+
admin_username
|
6
|
+
admin_password
|
7
|
+
doc_expansion
|
8
|
+
json_editor
|
9
|
+
model_rendering
|
10
|
+
oauth_client_id
|
11
|
+
oauth_client_secret
|
12
|
+
oauth_realm
|
13
|
+
oauth_app_name
|
14
|
+
oauth_scope_separator
|
15
|
+
oauth_query_string_params
|
16
|
+
request_headers
|
17
|
+
swagger_url
|
18
|
+
translator_enabled
|
19
|
+
validator_enabled
|
20
|
+
).freeze
|
21
|
+
|
22
|
+
attr_accessor(*OPTIONS)
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module SwaggerUiEngineRails7
|
2
|
+
DEFAULTS = {
|
3
|
+
swagger_url: 'http://petstore.swagger.io/v2/swagger.json',
|
4
|
+
doc_expansion: 'none',
|
5
|
+
json_editor: false,
|
6
|
+
model_rendering: 'schema',
|
7
|
+
request_headers: false,
|
8
|
+
validator_url: '//online.swagger.io/validator'
|
9
|
+
}.freeze
|
10
|
+
|
11
|
+
OAUTH2_DEFAULTS = {
|
12
|
+
oauth_app_name: 'your-app-name',
|
13
|
+
oauth_client_id: 'your-client-id',
|
14
|
+
oauth_client_secret: 'your-client-secret-if-required',
|
15
|
+
oauth_realm: 'your-realms',
|
16
|
+
oauth_scope_separator: ' ',
|
17
|
+
oauth_query_string_params: {}
|
18
|
+
}.freeze
|
19
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'sassc/rails'
|
2
|
+
|
3
|
+
module SwaggerUiEngineRails7
|
4
|
+
class Engine < ::Rails::Engine
|
5
|
+
isolate_namespace SwaggerUiEngineRails7
|
6
|
+
|
7
|
+
config.to_prepare do
|
8
|
+
Rails.application.config.assets.precompile += %w[
|
9
|
+
swagger_ui_engine/lib/typography.css
|
10
|
+
swagger_ui_engine/lib/reset.css
|
11
|
+
swagger_ui_engine/lib/screen.css
|
12
|
+
swagger_ui_engine/lib/print.css
|
13
|
+
swagger_ui_engine/custom.css
|
14
|
+
swagger_ui_engine/print.css
|
15
|
+
swagger_ui_engine/logo_small.png
|
16
|
+
swagger_ui_engine/favicon-32x32.png
|
17
|
+
swagger_ui_engine/favicon-16x16.png
|
18
|
+
swagger_ui_engine/lang/*.js
|
19
|
+
swagger_ui_engine/DroidSans-Bold.ttf
|
20
|
+
swagger_ui_engine/DroidSans.ttf
|
21
|
+
swagger_ui_engine/application.js
|
22
|
+
swagger_ui_engine/application.css
|
23
|
+
]
|
24
|
+
|
25
|
+
Rails.application.config.assets.paths << Rails.root.join('vendor', 'assets', 'fonts')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rails/engine'
|
2
|
+
require 'action_controller/railtie'
|
3
|
+
require 'swagger_ui_engine_rails7/engine'
|
4
|
+
require 'swagger_ui_engine_rails7/version'
|
5
|
+
require 'swagger_ui_engine_rails7/configuration'
|
6
|
+
require 'swagger_ui_engine_rails7/defaults'
|
7
|
+
|
8
|
+
module SwaggerUiEngineRails7
|
9
|
+
class << self
|
10
|
+
delegate(*Configuration::OPTIONS, to: :configuration)
|
11
|
+
|
12
|
+
def configuration
|
13
|
+
@configuration ||= Configuration.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def configure
|
17
|
+
yield configuration
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: swagger_ui_engine_rails7
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.2.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- negabaro
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-03-23 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: '6'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sassc-rails
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Mount Swagger UI web console as Rails engine, configure it as you want
|
42
|
+
and write your API documentation in simple YAML files.
|
43
|
+
email:
|
44
|
+
- negabaro@gmail.com
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- CHANGELOG.md
|
50
|
+
- MIT-LICENSE
|
51
|
+
- Rakefile
|
52
|
+
- app/assets/fonts/swagger_ui_engine/DroidSans-Bold.ttf
|
53
|
+
- app/assets/fonts/swagger_ui_engine/DroidSans.ttf
|
54
|
+
- app/assets/images/swagger_ui_engine/collapse.gif
|
55
|
+
- app/assets/images/swagger_ui_engine/expand.gif
|
56
|
+
- app/assets/images/swagger_ui_engine/explorer_icons.png
|
57
|
+
- app/assets/images/swagger_ui_engine/favicon-16x16.png
|
58
|
+
- app/assets/images/swagger_ui_engine/favicon-32x32.png
|
59
|
+
- app/assets/images/swagger_ui_engine/favicon.ico
|
60
|
+
- app/assets/images/swagger_ui_engine/logo_small.png
|
61
|
+
- app/assets/images/swagger_ui_engine/pet_store_api.png
|
62
|
+
- app/assets/images/swagger_ui_engine/throbber.gif
|
63
|
+
- app/assets/images/swagger_ui_engine/wordnik_api.png
|
64
|
+
- app/assets/javascripts/swagger_ui_engine/application.js
|
65
|
+
- app/assets/javascripts/swagger_ui_engine/lang/ca.js
|
66
|
+
- app/assets/javascripts/swagger_ui_engine/lang/de.js
|
67
|
+
- app/assets/javascripts/swagger_ui_engine/lang/el.js
|
68
|
+
- app/assets/javascripts/swagger_ui_engine/lang/en.js
|
69
|
+
- app/assets/javascripts/swagger_ui_engine/lang/es.js
|
70
|
+
- app/assets/javascripts/swagger_ui_engine/lang/fr.js
|
71
|
+
- app/assets/javascripts/swagger_ui_engine/lang/geo.js
|
72
|
+
- app/assets/javascripts/swagger_ui_engine/lang/it.js
|
73
|
+
- app/assets/javascripts/swagger_ui_engine/lang/ja.js
|
74
|
+
- app/assets/javascripts/swagger_ui_engine/lang/ko-kr.js
|
75
|
+
- app/assets/javascripts/swagger_ui_engine/lang/pl.js
|
76
|
+
- app/assets/javascripts/swagger_ui_engine/lang/pt.js
|
77
|
+
- app/assets/javascripts/swagger_ui_engine/lang/ru.js
|
78
|
+
- app/assets/javascripts/swagger_ui_engine/lang/tr.js
|
79
|
+
- app/assets/javascripts/swagger_ui_engine/lang/translator.js
|
80
|
+
- app/assets/javascripts/swagger_ui_engine/lang/zh-cn.js
|
81
|
+
- app/assets/javascripts/swagger_ui_engine/lib/backbone-min.js
|
82
|
+
- app/assets/javascripts/swagger_ui_engine/lib/es5-shim.js
|
83
|
+
- app/assets/javascripts/swagger_ui_engine/lib/handlebars-4.0.5.js
|
84
|
+
- app/assets/javascripts/swagger_ui_engine/lib/highlight.9.1.0.pack.js
|
85
|
+
- app/assets/javascripts/swagger_ui_engine/lib/highlight.9.1.0.pack_extended.js
|
86
|
+
- app/assets/javascripts/swagger_ui_engine/lib/jquery-1.8.0.min.js
|
87
|
+
- app/assets/javascripts/swagger_ui_engine/lib/jquery.ba-bbq.min.js
|
88
|
+
- app/assets/javascripts/swagger_ui_engine/lib/jquery.slideto.min.js
|
89
|
+
- app/assets/javascripts/swagger_ui_engine/lib/jquery.wiggle.min.js
|
90
|
+
- app/assets/javascripts/swagger_ui_engine/lib/js-yaml.min.js
|
91
|
+
- app/assets/javascripts/swagger_ui_engine/lib/jsoneditor.min.js
|
92
|
+
- app/assets/javascripts/swagger_ui_engine/lib/lodash.min.js
|
93
|
+
- app/assets/javascripts/swagger_ui_engine/lib/marked.js
|
94
|
+
- app/assets/javascripts/swagger_ui_engine/lib/object-assign-pollyfill.js
|
95
|
+
- app/assets/javascripts/swagger_ui_engine/lib/sanitize-html.min.js
|
96
|
+
- app/assets/javascripts/swagger_ui_engine/lib/swagger-oauth.js
|
97
|
+
- app/assets/javascripts/swagger_ui_engine/swagger-ui.js
|
98
|
+
- app/assets/javascripts/swagger_ui_engine/swagger-ui.min.js
|
99
|
+
- app/assets/javascripts/swagger_ui_engine/swagger.json
|
100
|
+
- app/assets/stylesheets/swagger_ui_engine/application.css
|
101
|
+
- app/assets/stylesheets/swagger_ui_engine/custom.css
|
102
|
+
- app/assets/stylesheets/swagger_ui_engine/lib/print.css.erb
|
103
|
+
- app/assets/stylesheets/swagger_ui_engine/lib/reset.css
|
104
|
+
- app/assets/stylesheets/swagger_ui_engine/lib/screen.css.erb
|
105
|
+
- app/assets/stylesheets/swagger_ui_engine/lib/style.css
|
106
|
+
- app/assets/stylesheets/swagger_ui_engine/lib/typography.css.erb
|
107
|
+
- app/assets/stylesheets/swagger_ui_engine/print.css
|
108
|
+
- app/controllers/swagger_ui_engine/application_controller.rb
|
109
|
+
- app/controllers/swagger_ui_engine/swagger_docs_controller.rb
|
110
|
+
- app/helpers/swagger_ui_engine/auth_config_parser.rb
|
111
|
+
- app/helpers/swagger_ui_engine/config_parser.rb
|
112
|
+
- app/helpers/swagger_ui_engine/oauth_config_parser.rb
|
113
|
+
- app/helpers/swagger_ui_engine/translation_helper.rb
|
114
|
+
- app/views/swagger_ui_engine/layouts/swagger.html.erb
|
115
|
+
- app/views/swagger_ui_engine/swagger_docs/index.html.erb
|
116
|
+
- app/views/swagger_ui_engine/swagger_docs/oauth2.html.erb
|
117
|
+
- app/views/swagger_ui_engine/swagger_docs/show.html.erb
|
118
|
+
- config/routes.rb
|
119
|
+
- lib/swagger_ui_engine_rails7.rb
|
120
|
+
- lib/swagger_ui_engine_rails7/configuration.rb
|
121
|
+
- lib/swagger_ui_engine_rails7/defaults.rb
|
122
|
+
- lib/swagger_ui_engine_rails7/engine.rb
|
123
|
+
- lib/swagger_ui_engine_rails7/version.rb
|
124
|
+
homepage: https://github.com/negabaro/swagger_ui_engine_rails7
|
125
|
+
licenses:
|
126
|
+
- MIT
|
127
|
+
metadata: {}
|
128
|
+
post_install_message:
|
129
|
+
rdoc_options: []
|
130
|
+
require_paths:
|
131
|
+
- lib
|
132
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
requirements: []
|
143
|
+
rubygems_version: 3.4.22
|
144
|
+
signing_key:
|
145
|
+
specification_version: 4
|
146
|
+
summary: Mountable Rails engine that serves Swagger UI for your API documentation
|
147
|
+
written in YAML files.
|
148
|
+
test_files: []
|