mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 23:59:26 +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
|
||||
// file that was distributed with this source code.
|
||||
|
||||
window.onload = function() {
|
||||
function loadSwaggerUI(userOptions = {}) {
|
||||
const data = JSON.parse(document.getElementById('swagger-data').innerText);
|
||||
const ui = SwaggerUIBundle({
|
||||
const defaultOptions = {
|
||||
spec: data.spec,
|
||||
dom_id: '#swagger-ui',
|
||||
validatorUrl: null,
|
||||
@ -19,7 +19,9 @@ window.onload = function() {
|
||||
SwaggerUIBundle.plugins.DownloadUrl
|
||||
],
|
||||
layout: 'StandaloneLayout'
|
||||
});
|
||||
};
|
||||
const options = Object.assign({}, defaultOptions, userOptions);
|
||||
const ui = SwaggerUIBundle(options);
|
||||
|
||||
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>
|
||||
{% endblock javascripts %}
|
||||
|
||||
<script src="{{ asset('bundles/nelmioapidoc/init-swagger-ui.js') }}"></script>
|
||||
{% block swagger_initialization %}
|
||||
<script src="{{ asset('bundles/nelmioapidoc/init-swagger-ui.js') }}"></script>
|
||||
<script type="text/javascript">
|
||||
window.onload = loadSwaggerUI();
|
||||
</script>
|
||||
{% endblock swagger_initialization %}
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
x
Reference in New Issue
Block a user