vendor/gollumsf/rest-doc-bundle/src/Resources/views/SwaggerUI/index.html.twig line 1

Open in your IDE?
  1. {# This file is part of the API Platform project.
  2. (c) Kévin Dunglas <dunglas@gmail.com>
  3. For the full copyright and license information, please view the LICENSE
  4. file that was distributed with this source code. #}
  5. <!DOCTYPE html>
  6. <html>
  7. <head>
  8.     {% block meta %}
  9.         <meta charset="UTF-8">
  10.     {% endblock meta %}
  11.     <title>{% block title %}{{ swaggerData.info.title }}{% endblock title %}</title>
  12.     {% block stylesheets %}
  13.         <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/3.23.11/swagger-ui.css">
  14.     {% endblock stylesheets %}
  15.     {% block swagger_data %}
  16.         {# json_encode(65) is for JSON_UNESCAPED_SLASHES|JSON_HEX_TAG to avoid JS XSS #}
  17.         <script id="swagger-data" type="application/json">{{ swaggerData|json_encode(65)|raw }}</script>
  18.     {% endblock swagger_data %}
  19. </head>
  20. <body>
  21. {% block swagger_ui %}
  22.     <div id="swagger-ui"></div>
  23. {% endblock %}
  24. {% block javascripts %}
  25.     <script src="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/3.23.11/swagger-ui-bundle.js"></script>
  26.     <script src="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/3.23.11/swagger-ui-standalone-preset.js"></script>
  27. {% endblock javascripts %}
  28. {% block swagger_initialization %}
  29.     <script>
  30.         window.onload = function() {
  31.             var data = JSON.parse(document.getElementById('swagger-data').innerText);
  32.             
  33.             // Begin Swagger UI call region
  34.             window.ui = SwaggerUIBundle({
  35.                 spec: data,
  36.                 dom_id: '#swagger-ui',
  37.                 validatorUrl: null,
  38.                 presets: [
  39.                     SwaggerUIBundle.presets.apis,
  40.                     SwaggerUIStandalonePreset.slice(1) // here
  41.                 ],
  42.                 plugins: [
  43.                     SwaggerUIBundle.plugins.DownloadUrl
  44.                 ],
  45.                 layout: "StandaloneLayout"
  46.             });
  47.             var btnAuth = document.querySelector('.auth-wrapper .btn.authorize');
  48.             if (btnAuth) {
  49.                 btnAuth.addEventListener('click', function() {
  50.                     setTimeout(function() {
  51.                         if (data.components && data.components.securitySchemes)  {
  52.                             var i = 0;
  53.                             for (var name in data.components.securitySchemes) {
  54.                                 var security = data.components.securitySchemes[name];
  55.                                 if (security.defaultValue) {
  56.                                     var input = document.querySelector('.auth-wrapper .auth-container:nth-child('+(i+1)+') input');
  57.                                     if(input && !input.value) {
  58.                                         input.value = security.defaultValue;
  59.     
  60.                                         var event = new Event('change', {bubbles: true});
  61.                                         event.simulated = true;
  62.                                         input.dispatchEvent(event);
  63.                                     }
  64.                                 }
  65.                                 i++;
  66.                             }
  67.                         }
  68.                     }, 100);
  69.                 });
  70.             }
  71.         }
  72.     </script>
  73. {% endblock swagger_initialization %}
  74. </body>
  75. </html>