github.com/qubitproducts/logspray@v0.2.14/server/swagger-ui/test/unit/mock.js (about)

     1  /* jshint ignore:start */
     2  $(function () {
     3    'use strict';
     4    var url = window.location.search.match(/url=([^&]+)/);
     5    if (url && url.length > 1) {
     6      url = decodeURIComponent(url[1]);
     7    } else {
     8      url = 'http://petstore.swagger.io/v2/swagger.json';
     9    }
    10  
    11    // Pre load translate...
    12    if(window.SwaggerTranslator) {
    13      window.SwaggerTranslator.translate();
    14    }
    15    window.swaggerUi = new SwaggerUi({
    16      url: url,
    17      dom_id: 'swagger-ui-container',
    18      supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
    19      onComplete: function(){
    20        if(typeof initOAuth === 'function') {
    21          initOAuth({
    22            clientId: 'your-client-id',
    23            clientSecret: 'your-client-secret-if-required',
    24            realm: 'your-realms',
    25            appName: 'your-app-name',
    26            scopeSeparator: ',',
    27            additionalQueryStringParams: {}
    28          });
    29        }
    30  
    31        if(window.SwaggerTranslator) {
    32          window.SwaggerTranslator.translate();
    33        }
    34  
    35        $('pre code').each(function(i, e) {
    36          hljs.highlightBlock(e);
    37        });
    38  
    39      },
    40      onFailure: function() {
    41        log('Unable to Load SwaggerUI');
    42      },
    43      docExpansion: 'none',
    44      jsonEditor: false,
    45      apisSorter: 'alpha',
    46      defaultModelRendering: 'schema',
    47      showRequestHeaders: false
    48    });
    49  
    50    window.swaggerUi.load();
    51  
    52    function log() {
    53      if ('console' in window) {
    54        console.log.apply(console, arguments);
    55      }
    56    }
    57  });
    58  
    59  /* jshint ignore:end */