Update ReDoc settings
parent
10abf46597
commit
4bac38e67b
|
|
@ -10,6 +10,7 @@ Changelog
|
|||
*Release date: Sep 10, 2018*
|
||||
|
||||
- **ADDED:** added the ``SPEC_URL`` setting for controlling the download link in ``swagger-ui`` and ``ReDoc``
|
||||
- **ADDED:** updated ``ReDoc`` settings (added ``NATIVE_SCROLLBARS`` and ``REQUIRED_PROPS_FIRST``)
|
||||
- **IMPROVED:** updated ``swagger-ui`` to version 3.18.2
|
||||
- **IMPROVED:** updated ``ReDoc`` to version 2.0.0-alpha.37
|
||||
- **FIXED:** stopped generating invalid OpenAPI by improper placement of ``readOnly`` Schemas
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ Example:
|
|||
}
|
||||
|
||||
REDOC_SETTINGS = {
|
||||
'LAZY_RENDERING': True,
|
||||
'LAZY_RENDERING': False,
|
||||
...
|
||||
}
|
||||
|
||||
|
|
@ -356,26 +356,40 @@ URL which serves the UI; see :ref:`note on URL settings <url-settings>` above.
|
|||
LAZY_RENDERING
|
||||
--------------
|
||||
|
||||
**Default**: :python:`True` |br|
|
||||
*Maps to attribute*: ``lazy-rendering``
|
||||
**NOTE:** this feature might be removed in future versions of ReDoc (see https://github.com/Rebilly/ReDoc/issues/475)
|
||||
|
||||
**Default**: :python:`False` |br|
|
||||
*Maps to attribute*: ``lazyRendering``
|
||||
|
||||
HIDE_HOSTNAME
|
||||
-------------
|
||||
|
||||
**Default**: :python:`False` |br|
|
||||
*Maps to attribute*: ``hide-hostname``
|
||||
*Maps to attribute*: ``hideHostname``
|
||||
|
||||
EXPAND_RESPONSES
|
||||
----------------
|
||||
|
||||
**Default**: :python:`'all'` |br|
|
||||
*Maps to attribute*: ``expand-responses``
|
||||
*Maps to attribute*: ``expandResponses``
|
||||
|
||||
PATH_IN_MIDDLE
|
||||
--------------
|
||||
|
||||
**Default**: :python:`False` |br|
|
||||
*Maps to attribute*: ``path-in-middle-panel``
|
||||
*Maps to attribute*: ``pathInMiddlePanel``
|
||||
|
||||
NATIVE_SCROLLBARS
|
||||
-----------------
|
||||
|
||||
**Default**: :python:`False` |br|
|
||||
*Maps to attribute*: ``nativeScrollbars``
|
||||
|
||||
REQUIRED_PROPS_FIRST
|
||||
--------------------
|
||||
|
||||
**Default**: :python:`False` |br|
|
||||
*Maps to attribute*: ``requiredPropsFirst``
|
||||
|
||||
|
||||
.. _FORCE_SCRIPT_NAME: https://docs.djangoproject.com/en/2.0/ref/settings/#force-script-name
|
||||
|
|
|
|||
|
|
@ -67,10 +67,12 @@ SWAGGER_DEFAULTS = {
|
|||
|
||||
REDOC_DEFAULTS = {
|
||||
'SPEC_URL': None,
|
||||
'LAZY_RENDERING': True,
|
||||
'LAZY_RENDERING': False,
|
||||
'HIDE_HOSTNAME': False,
|
||||
'EXPAND_RESPONSES': 'all',
|
||||
'PATH_IN_MIDDLE': False,
|
||||
'NATIVE_SCROLLBARS': False,
|
||||
'REQUIRED_PROPS_FIRST': False,
|
||||
}
|
||||
|
||||
IMPORT_STRINGS = [
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import warnings
|
||||
|
||||
import six
|
||||
|
||||
from django.shortcuts import render, resolve_url
|
||||
|
|
@ -157,7 +159,9 @@ class ReDocRenderer(_UIRenderer):
|
|||
'lazyRendering': redoc_settings.LAZY_RENDERING,
|
||||
'hideHostname': redoc_settings.HIDE_HOSTNAME,
|
||||
'expandResponses': redoc_settings.EXPAND_RESPONSES,
|
||||
'pathInMiddle': redoc_settings.PATH_IN_MIDDLE,
|
||||
'pathInMiddlePanel': redoc_settings.PATH_IN_MIDDLE,
|
||||
'nativeScrollbars': redoc_settings.NATIVE_SCROLLBARS,
|
||||
'requiredPropsFirst': redoc_settings.REQUIRED_PROPS_FIRST,
|
||||
}
|
||||
|
||||
return filter_none(data)
|
||||
|
|
|
|||
|
|
@ -7,19 +7,22 @@ var redoc = document.createElement("redoc");
|
|||
var redocSettings = JSON.parse(document.getElementById('redoc-settings').innerHTML);
|
||||
if (redocSettings.url) {
|
||||
specURL = redocSettings.url;
|
||||
delete redocSettings.url;
|
||||
}
|
||||
redoc.setAttribute("spec-url", specURL);
|
||||
|
||||
if (redocSettings.lazyRendering) {
|
||||
redoc.setAttribute("lazy-rendering", '');
|
||||
function camelToKebab(str) {
|
||||
return str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
|
||||
}
|
||||
if (redocSettings.pathInMiddle) {
|
||||
redoc.setAttribute("path-in-middle-panel", '');
|
||||
|
||||
for (var p in redocSettings) {
|
||||
if (redocSettings.hasOwnProperty(p)) {
|
||||
if (redocSettings[p] !== null && redocSettings[p] !== undefined && redocSettings[p] !== false) {
|
||||
redoc.setAttribute(camelToKebab(p), redocSettings[p].toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (redocSettings.hideHostname) {
|
||||
redoc.setAttribute("hide-hostname", '');
|
||||
}
|
||||
redoc.setAttribute("expand-responses", redocSettings.expandResponses);
|
||||
|
||||
document.body.appendChild(redoc);
|
||||
|
||||
function hideEmptyVersion() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue