Merge "Add message to update the schema context of the InMemoryDOMDataStore"
[controller.git] / opendaylight / md-sal / sal-rest-docgen / src / main / resources / explorer / lib / odl / swagger.js
1
2 //There can only be a single swagger UI in a dom tree
3 //at a time - this is a limitation of the swagger API
4 //This method takes a URL which is the root of the swagger
5 //documentation, as well as the ID of the dom where we should
6 //load the swagger UI.
7 //See the swagger documentation for more information.
8 var loadSwagger = function(url, dom_id) {
9     $("#" + dom_id).empty();
10     $("#" + dom_id).append("Loading " + url);
11     window.swaggerUi = new SwaggerUi({
12         url : url,
13         dom_id : dom_id,
14         supportedSubmitMethods : [ 'get', 'post', 'put', 'delete' ],
15         onComplete : function(swaggerApi, swaggerUi) {
16             if (console) {
17                 console.log("Loaded SwaggerUI")
18             }
19             $('pre code').each(function(i, e) {
20                 hljs.highlightBlock(e)
21             });
22         },
23         onFailure : function(data) {
24             if (console) {
25                 console.log("Unable to Load SwaggerUI");
26                 console.log(data);
27             }
28         },
29         docExpansion : "none"
30     });
31
32     $('#input_apiKey').change(
33             function() {
34                 var key = $('#input_apiKey')[0].value;
35                 console.log("key: " + key);
36                 if (key && key.trim() != "") {
37                     console.log("added key " + key);
38                     window.authorizations
39                             .add("key", new ApiKeyAuthorization("api_key",
40                                     key, "query"));
41                 }
42             });
43     window.swaggerUi.load();
44 }