mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-10 03:29:25 +03:00
Allow to pass options to the constructor of SwaggerUIBundle
This commit is contained in:
parent
2f8416618d
commit
cbab00939f
@ -5,9 +5,9 @@
|
|||||||
// For the full copyright and license information, please view the LICENSE
|
// For the full copyright and license information, please view the LICENSE
|
||||||
// file that was distributed with this source code.
|
// file that was distributed with this source code.
|
||||||
|
|
||||||
window.onload = function() {
|
function loadSwaggerUI(userOptions = {}) {
|
||||||
const data = JSON.parse(document.getElementById('swagger-data').innerText);
|
const data = JSON.parse(document.getElementById('swagger-data').innerText);
|
||||||
const ui = SwaggerUIBundle({
|
const defaultOptions = {
|
||||||
spec: data.spec,
|
spec: data.spec,
|
||||||
dom_id: '#swagger-ui',
|
dom_id: '#swagger-ui',
|
||||||
validatorUrl: null,
|
validatorUrl: null,
|
||||||
@ -19,7 +19,9 @@ window.onload = function() {
|
|||||||
SwaggerUIBundle.plugins.DownloadUrl
|
SwaggerUIBundle.plugins.DownloadUrl
|
||||||
],
|
],
|
||||||
layout: 'StandaloneLayout'
|
layout: 'StandaloneLayout'
|
||||||
});
|
};
|
||||||
|
const options = Object.assign({}, defaultOptions, userOptions);
|
||||||
|
const ui = SwaggerUIBundle(options);
|
||||||
|
|
||||||
const storageKey = 'nelmio_api_auth';
|
const storageKey = 'nelmio_api_auth';
|
||||||
|
|
||||||
|
@ -66,8 +66,11 @@ file that was distributed with this source code. #}
|
|||||||
<script src="{{ asset('bundles/nelmioapidoc/swagger-ui/swagger-ui-standalone-preset.js') }}"></script>
|
<script src="{{ asset('bundles/nelmioapidoc/swagger-ui/swagger-ui-standalone-preset.js') }}"></script>
|
||||||
{% endblock javascripts %}
|
{% endblock javascripts %}
|
||||||
|
|
||||||
|
<script src="{{ asset('bundles/nelmioapidoc/init-swagger-ui.js') }}"></script>
|
||||||
{% block swagger_initialization %}
|
{% block swagger_initialization %}
|
||||||
<script src="{{ asset('bundles/nelmioapidoc/init-swagger-ui.js') }}"></script>
|
<script type="text/javascript">
|
||||||
|
window.onload = loadSwaggerUI();
|
||||||
|
</script>
|
||||||
{% endblock swagger_initialization %}
|
{% endblock swagger_initialization %}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user