Sha256: b4e4e1e65eb1dfe8424e08cb08df26bfd20ac74c636abed593d662cccf69675e

Contents?: true

Size: 1.73 KB

Versions: 5

Compression:

Stored size: 1.73 KB

Contents

$(function () {
    var url = window.location.search.match(/url=([^&]+)/);
    if (url && url.length > 1) {
        url = decodeURIComponent(url[1]);
    } else {
        url = "/api/api-docs.json";
    }
    window.swaggerUi = new SwaggerUi({
        url: url,
        dom_id: "swagger-ui-container",
        supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
        onComplete: function(swaggerApi, swaggerUi){
            if(typeof initOAuth == "function") {
                /*
                 initOAuth({
                 clientId: "your-client-id",
                 realm: "your-realms",
                 appName: "your-app-name"
                 });
                 */
            }
            $('pre code').each(function(i, e) {
                hljs.highlightBlock(e)
            });
        },
        onFailure: function(data) {
            log("Unable to Load SwaggerUI");
        },
        docExpansion: "list",
        sorter: "method"
    });

    function addApiKeyAuthorization() {
        var key = $('#input_apiKey')[0].value;
        log("key: " + key);
        if(key && key.trim() != "") {
            log("added key " + key);
            window.authorizations.add("api_key", new ApiKeyAuthorization("api_key", key, "query"));
        }
    }

    $('#input_apiKey').change(function() {
        addApiKeyAuthorization();
    });

    // if you have an apiKey you would like to pre-populate on the page for demonstration purposes...
    /*
     var apiKey = "myApiKeyXXXX123456789";
     $('#input_apiKey').val(apiKey);
     addApiKeyAuthorization();
     */
    window.authorizations.add('X-CSRF-Token', new ApiKeyAuthorization("X-CSRF-Token", $("meta[name='csrf-token']").attr("content"), "header"));
    window.swaggerUi.load();
});

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ddy_swagger_docs-0.0.5 vendor/assets/javascripts/initializer.js
ddy_swagger_docs-0.0.4 vendor/assets/javascripts/initializer.js
ddy_swagger_docs-0.0.3 vendor/assets/javascripts/initializer.js
ddy_swagger_docs-0.0.2 vendor/assets/javascripts/initializer.js
ddy_swagger_docs-0.0.1 vendor/assets/javascripts/initializer.js