Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated swagger-ui-3.52.0 #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 61 additions & 95 deletions app/views/layouts/swagger.html.erb
Original file line number Diff line number Diff line change
@@ -1,96 +1,62 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="<%= I18n.locale.to_s %>" xml:lang="<%= I18n.locale.to_s %>" xmlns="http://www.w3.org/1999/xhtml">
<head>
<!-- HTML for static distribution bundle build -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Swagger UI</title>
<%= javascript_include_tag :swagger_ui %>
<%= stylesheet_link_tag "//fonts.googleapis.com/css?family=Droid+Sans:400,700" %>
<%= stylesheet_link_tag :swagger_ui_screen, :media => :screen %>
<%= stylesheet_link_tag :swagger_ui_print, :media => :print %>
<%= csrf_meta_tags %>

<script type="text/javascript">
$(function () {
var url = window.location.search.match(/url=([^&]+)/);
if (url && url.length > 1) {
url = decodeURIComponent(url[1]);
} else {
url = "<%= request.protocol %><%= request.host%>:<%=request.port%>/api/v1/swagger_doc";
}

hljs.configure({
highlightSizeThreshold: 5000
});

// Pre load translate...
if(window.SwaggerTranslator) {
window.SwaggerTranslator.translate();
}
window.swaggerUi = new SwaggerUi({
url: url,
dom_id: "swagger-ui-container",
supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
onComplete: function(swaggerApi, swaggerUi){
if(typeof initOAuth == "function") {
initOAuth({
clientId: "your-client-id",
clientSecret: "your-client-secret-if-required",
realm: "your-realms",
appName: "your-app-name",
scopeSeparator: ",",
additionalQueryStringParams: {}
});
}

if(window.SwaggerTranslator) {
window.SwaggerTranslator.translate();
}
},
onFailure: function(data) {
log("Unable to Load SwaggerUI");
},
docExpansion: "none",
jsonEditor: false,
defaultModelRendering: 'schema',
showRequestHeaders: false
});

$('#input_apiKey').change(function() {
var key = $('#input_apiKey')[0].value;
if(key && key.trim() != "") {
swaggerUi.api.clientAuthorizations.add("key", new SwaggerClient.ApiKeyAuthorization("api_key", key, "query"));
}
})

window.swaggerUi.load();

function log() {
if ('console' in window) {
console.log.apply(console, arguments);
}
}
});
</script>

</head>


<body class="swagger-section">
<div id='header'>
<div class="swagger-ui-wrap">
<a id="logo" href="http://swagger.io"><span class="logo__title">swagger</span></a>
<form id='api_selector'>
<div class='input'><input placeholder="http://example.com/api" id="input_baseUrl" name="baseUrl" type="text"/></div>
<div class="input">
<input id="input_apiKey" name="apiKey" placeholder="api_key" type="text"></input>
</div>
<div id='auth_container'></div>
<div class='input'><a id="explore" class="header__btn" href="#" data-sw-translate>Explore</a></div>
</form>
</div>
</div>

<div id="message-bar" class="swagger-ui-wrap" data-sw-translate>&nbsp;</div>
<div id="swagger-ui-container" class="swagger-ui-wrap"></div>
</body>

</html>
<%= stylesheet_link_tag :swagger_ui%>
<%# <link rel="stylesheet" type="text/css" href="./swagger-ui.css" /> %>
<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
<style>
html
{
box-sizing: border-box;
overflow: -moz-scrollbars-vertical;
overflow-y: scroll;
}

*,
*:before,
*:after
{
box-sizing: inherit;
}

body
{
margin:0;
background: #fafafa;
}
</style>
</head>

<body>
<div id="swagger-ui"></div>

<%= javascript_include_tag :swagger_ui_bundle %>
<%= javascript_include_tag :swagger_ui_standalone_preset %>

<script>
window.onload = function() {
// Begin Swagger UI call region
const ui = SwaggerUIBundle({
url: "https://petstore.swagger.io/v2/swagger.json",
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout"
});
// End Swagger UI call region

window.ui = ui;
};
</script>
</body>
</html>
150 changes: 53 additions & 97 deletions lib/generators/swagger/layout/templates/swagger.html.erb
Original file line number Diff line number Diff line change
@@ -1,106 +1,62 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="<%%= I18n.locale.to_s %>" xml:lang="<%%= I18n.locale.to_s %>" xmlns="http://www.w3.org/1999/xhtml">
<!-- HTML for static distribution bundle build -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Swagger UI</title>
<%%= javascript_include_tag :swagger_ui %>
<%%= stylesheet_link_tag :swagger_ui_screen, :media => :screen %>
<%%= stylesheet_link_tag :swagger_ui_print, :media => :print %>
<%%= csrf_meta_tags %>
<style>
.swagger-ui-wrap {
max-width: 80%;
min-width: 960px;
margin-left: auto;
margin-right: auto;
<%= stylesheet_link_tag :swagger_ui%>
<%# <link rel="stylesheet" type="text/css" href="./swagger-ui.css" /> %>
<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
<style>
html
{
box-sizing: border-box;
overflow: -moz-scrollbars-vertical;
overflow-y: scroll;
}
</style>

<script>
$(function () {
var url = window.location.search.match(/url=([^&]+)/);
if (url && url.length > 1) {
url = decodeURIComponent(url[1]);
} else {
url = "<%%= request.protocol %><%%= request.host %>:<%%= request.port %>/api/v1/swagger_doc";
}

hljs.configure({
highlightSizeThreshold: 5000
});

// Pre load translate...
if(window.SwaggerTranslator) {
window.SwaggerTranslator.translate();
}
window.swaggerUi = new SwaggerUi({
url: url,
dom_id: "swagger-ui-container",
supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
onComplete: function(swaggerApi, swaggerUi){
if(typeof initOAuth == "function") {
initOAuth({
clientId: "your-client-id",
clientSecret: "your-client-secret-if-required",
realm: "your-realms",
appName: "your-app-name",
scopeSeparator: ",",
additionalQueryStringParams: {}
});
}

if(window.SwaggerTranslator) {
window.SwaggerTranslator.translate();
}
},
onFailure: function(data) {
log("Unable to Load SwaggerUI");
},
docExpansion: "none",
jsonEditor: false,
defaultModelRendering: 'schema',
showRequestHeaders: false
});

$('#input_apiKey').change(function() {
var key = $('#input_apiKey')[0].value;
if(key && key.trim() != "") {
swaggerUi.api.clientAuthorizations.add("key", new SwaggerClient.ApiKeyAuthorization("api_key", key, "query"));
}
})
*,
*:before,
*:after
{
box-sizing: inherit;
}

window.swaggerUi.load();
body
{
margin:0;
background: #fafafa;
}
</style>
</head>

function log() {
if ('console' in window) {
console.log.apply(console, arguments);
}
}
<body>
<div id="swagger-ui"></div>

<%= javascript_include_tag :swagger_ui_bundle %>
<%= javascript_include_tag :swagger_ui_standalone_preset %>

<script>
window.onload = function() {
// Begin Swagger UI call region
const ui = SwaggerUIBundle({
url: "https://petstore.swagger.io/v2/swagger.json",
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout"
});
// End Swagger UI call region


</script>
</head>
<body class="swagger-section">
<div id="header">
<div class="swagger-ui-wrap">
<a href="http://swagger.io" id="logo">
<span class="logo__title">swagger</span>
</a>
<form id="api_selector">
<div class="input">
<input id="input_baseUrl" name="baseUrl" placeholder="http://example.com/api" type="text">/</input>
</div>
<div class="input">
<input id="input_apiKey" name="apiKey" placeholder="api_key" type="text"></input>
</div>
<div id="auth_container"></div>
<div class="input">
<a class="header__btn" href="#" id="explore">Explore</a>
</div>
</form>
</div>
</div>
<div class="swagger-ui-wrap" id="message-bar">&nbsp;</div>
<div class="swagger-ui-wrap" id="swagger-ui-container"></div>
window.ui = ui;
};
</script>
</body>
</html>
</html>
Loading