Remove inline style from redoc
parent
55223e32e2
commit
59a51ba4a7
|
|
@ -17,3 +17,32 @@ if (redocSettings.hideHostname) {
|
||||||
}
|
}
|
||||||
redoc.setAttribute("expand-responses", redocSettings.expandResponses);
|
redoc.setAttribute("expand-responses", redocSettings.expandResponses);
|
||||||
document.body.appendChild(redoc);
|
document.body.appendChild(redoc);
|
||||||
|
|
||||||
|
function hideEmptyVersion() {
|
||||||
|
// 'span.api-info-version' is for redoc 1.x, 'div.api-info span' is for redoc 2-alpha
|
||||||
|
var apiVersion = document.querySelector('span.api-info-version') || document.querySelector('div.api-info span');
|
||||||
|
if (!apiVersion) {
|
||||||
|
console.log("WARNING: could not find API versionString element (span.api-info-version)");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var versionString = apiVersion.innerText;
|
||||||
|
if (versionString) {
|
||||||
|
// trim spaces and surrounding ()
|
||||||
|
versionString = versionString.replace(/ /g,'');
|
||||||
|
versionString = versionString.replace(/(^\()|(\)$)/g,'');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!versionString) {
|
||||||
|
// hide version element if empty
|
||||||
|
apiVersion.classList.add("hidden");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (document.querySelector('span.api-info-version') || document.querySelector('div.api-info span')) {
|
||||||
|
hideEmptyVersion();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
insertionQ('span.api-info-version').every(hideEmptyVersion);
|
||||||
|
insertionQ('div.api-info span').every(hideEmptyVersion);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,10 @@ html {
|
||||||
|
|
||||||
body {
|
body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
body.swagger-body {
|
||||||
background: #fafafa;
|
background: #fafafa;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ function patchSwaggerUi() {
|
||||||
var authorizeButton = document.querySelector('.auth-wrapper .authorize');
|
var authorizeButton = document.querySelector('.auth-wrapper .authorize');
|
||||||
var djangoSessionAuth = document.querySelector('#django-session-auth');
|
var djangoSessionAuth = document.querySelector('#django-session-auth');
|
||||||
if (document.querySelector('.auth-wrapper #django-session-auth')) {
|
if (document.querySelector('.auth-wrapper #django-session-auth')) {
|
||||||
console.log("session auth already patched");
|
console.log("WARNING: session auth already patched; skipping patchSwaggerUi()");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -20,6 +20,10 @@ function patchSwaggerUi() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function initSwaggerUi() {
|
function initSwaggerUi() {
|
||||||
|
if (window.ui) {
|
||||||
|
console.log("WARNING: skipping initSwaggerUi() because window.ui is already defined");
|
||||||
|
return;
|
||||||
|
}
|
||||||
var swaggerConfig = {
|
var swaggerConfig = {
|
||||||
url: specURL,
|
url: specURL,
|
||||||
dom_id: '#swagger-ui',
|
dom_id: '#swagger-ui',
|
||||||
|
|
@ -46,7 +50,6 @@ function initSwaggerUi() {
|
||||||
|
|
||||||
var swaggerSettings = JSON.parse(document.getElementById('swagger-settings').innerHTML);
|
var swaggerSettings = JSON.parse(document.getElementById('swagger-settings').innerHTML);
|
||||||
|
|
||||||
console.log(swaggerSettings);
|
|
||||||
for (var p in swaggerSettings) {
|
for (var p in swaggerSettings) {
|
||||||
if (swaggerSettings.hasOwnProperty(p)) {
|
if (swaggerSettings.hasOwnProperty(p)) {
|
||||||
swaggerConfig[p] = swaggerSettings[p];
|
swaggerConfig[p] = swaggerSettings[p];
|
||||||
|
|
@ -56,6 +59,12 @@ function initSwaggerUi() {
|
||||||
}
|
}
|
||||||
|
|
||||||
window.onload = function () {
|
window.onload = function () {
|
||||||
insertionQ('.auth-wrapper .authorize').every(patchSwaggerUi);
|
|
||||||
initSwaggerUi();
|
initSwaggerUi();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (document.querySelector('.auth-wrapper .authorize')) {
|
||||||
|
patchSwaggerUi();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
insertionQ('.auth-wrapper .authorize').every(patchSwaggerUi);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,21 +5,13 @@
|
||||||
<title>{{ title }}</title>
|
<title>{{ title }}</title>
|
||||||
<meta charset="utf-8"/>
|
<meta charset="utf-8"/>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<style>
|
|
||||||
body {
|
<link rel="stylesheet" type="text/css" href="{% static 'drf-yasg/style.css' %}"/>
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
{% if not request.version %}
|
|
||||||
span.api-info-version {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
{% endif %}
|
|
||||||
</style>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<script id="redoc-settings" type="application/json">{{ redoc_settings | safe }}</script>
|
<script id="redoc-settings" type="application/json">{{ redoc_settings | safe }}</script>
|
||||||
|
|
||||||
|
<script src="{% static 'drf-yasg/insQ.min.js' %}"></script>
|
||||||
<script src="{% static 'drf-yasg/redoc-init.js' %}"> </script>
|
<script src="{% static 'drf-yasg/redoc-init.js' %}"> </script>
|
||||||
<script src="{% static 'drf-yasg/redoc-alpha/redoc.standalone.js' %}"> </script>
|
<script src="{% static 'drf-yasg/redoc-alpha/redoc.standalone.js' %}"> </script>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
||||||
|
|
@ -5,22 +5,14 @@
|
||||||
<title>{{ title }}</title>
|
<title>{{ title }}</title>
|
||||||
<meta charset="utf-8"/>
|
<meta charset="utf-8"/>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<style>
|
|
||||||
body {
|
<link rel="stylesheet" type="text/css" href="{% static 'drf-yasg/style.css' %}"/>
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
{% if not request.version %}
|
|
||||||
span.api-info-version {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
{% endif %}
|
|
||||||
</style>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<script id="redoc-settings" type="application/json">{{ redoc_settings | safe }}</script>
|
<script id="redoc-settings" type="application/json">{{ redoc_settings | safe }}</script>
|
||||||
|
|
||||||
|
<script src="{% static 'drf-yasg/insQ.min.js' %}"></script>
|
||||||
<script src="{% static 'drf-yasg/redoc-init.js' %}"> </script>
|
<script src="{% static 'drf-yasg/redoc-init.js' %}"> </script>
|
||||||
<script src="{% static 'drf-yasg/redoc/redoc.min.js' %}"> </script>
|
<script src="{% static 'drf-yasg/redoc/redoc.min.js' %}"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body class="swagger-body">
|
||||||
|
|
||||||
<svg class="swagger-defs" xmlns="http://www.w3.org/2000/svg">
|
<svg class="swagger-defs" xmlns="http://www.w3.org/2000/svg">
|
||||||
<defs>
|
<defs>
|
||||||
|
|
@ -61,10 +61,10 @@
|
||||||
|
|
||||||
<script id="swagger-settings" type="application/json">{{ swagger_settings | safe }}</script>
|
<script id="swagger-settings" type="application/json">{{ swagger_settings | safe }}</script>
|
||||||
|
|
||||||
<script src="{% static 'drf-yasg/swagger-ui-init.js' %}"></script>
|
|
||||||
<script src="{% static 'drf-yasg/swagger-ui-dist/swagger-ui-bundle.js' %}"></script>
|
<script src="{% static 'drf-yasg/swagger-ui-dist/swagger-ui-bundle.js' %}"></script>
|
||||||
<script src="{% static 'drf-yasg/swagger-ui-dist/swagger-ui-standalone-preset.js' %}"></script>
|
<script src="{% static 'drf-yasg/swagger-ui-dist/swagger-ui-standalone-preset.js' %}"></script>
|
||||||
<script src="{% static 'drf-yasg/insQ.min.js' %}"></script>
|
<script src="{% static 'drf-yasg/insQ.min.js' %}"></script>
|
||||||
|
<script src="{% static 'drf-yasg/swagger-ui-init.js' %}"></script>
|
||||||
|
|
||||||
<div id="django-session-auth" class="hidden">
|
<div id="django-session-auth" class="hidden">
|
||||||
{% if USE_SESSION_AUTH %}
|
{% if USE_SESSION_AUTH %}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue