<%= javascript_include_tag "swagger-ui2" -%>
<%= javascript_include_tag "swagger-ui2/api_docs_proxy" %>
<%= javascript_include_tag "swagger-ui2/autocomplete" %>
<%= stylesheet_link_tag    "swagger-ui2/typography.css" %>
<%= stylesheet_link_tag    "swagger-ui2/screen.css" -%>

<%= stylesheet_link_tag    "swagger-ui/threescale" -%>

<div class="swagger-section">
  <div id="message-bar" class="swagger-ui-wrap">&nbsp;</div>
  <div id="swagger-ui-container" class="swagger-ui-wrap"></div>
</div>

<div class='apidocs-param-tips apidocs-signin-message' style='display:none;'>
  <p><a href='#'>Sign in</a> to your account for quick access to useful values.</p>
</div>

<script type="text/javascript">

  function log() {
    if ('console' in window) {
      console.log.apply(console, arguments);
    }
  }

  $(function () {
    var url = "<%= swagger_spec_url(services.first, format: :json) -%>";
    window.swaggerUi = new SwaggerUi({
      url: url,
      dom_id: "swagger-ui-container",
      supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
      apisSorter: "alpha", // can also be a function
      operationsSorter: "method", // can also be 'alpha' or a function
      onComplete: function(swaggerApi, swaggerUi) {
        $('#swagger-ui-container pre code').each(function(i, e) {hljs.highlightBlock(e)});
      },
      onFailure: function(data) {
        log("Unable to Load SwaggerUI");
      },
      docExpansion: "list",
      transport: function(httpClient, obj) {
        log("[swagger-ui]>>> custom transport.");
        return ApiDocsProxy.execute(httpClient, obj);
      }
    });

  });
</script>
