Revision ef485f52
Added by Andreas Kohlbecker almost 6 years ago
cdmlib-remote-webapp/src/main/webapp/doc/webjars/springfox-swagger-ui/springfox.js.diff | ||
---|---|---|
1 |
diff --git a/cdmlib-remote-webapp/src/main/webapp/doc/webjars/springfox-swagger-ui/springfox.js b/cdmlib-remote-webapp/src/main/webapp/doc/webjars/springfox-swagger-ui/springfox.js |
|
2 |
index 481fa73..4ad1d26 100644 |
|
3 |
--- a/cdmlib-remote-webapp/src/main/webapp/doc/webjars/springfox-swagger-ui/springfox.js |
|
4 |
+++ b/cdmlib-remote-webapp/src/main/webapp/doc/webjars/springfox-swagger-ui/springfox.js |
|
1 |
--- springfox.orig.js 2016-11-06 18:08:34.000000000 +0100 |
|
2 |
+++ springfox.js 2018-10-18 18:45:02.381106203 +0200 |
|
5 | 3 |
@@ -1,7 +1,7 @@ |
6 | 4 |
$(function() { |
7 | 5 |
var springfox = { |
... | ... | |
11 | 9 |
return urlMatches[1]; |
12 | 10 |
}, |
13 | 11 |
"securityConfig": function(cb) { |
14 |
@@ -16,13 +16,7 @@ $(function() {
|
|
12 |
@@ -16,8 +16,8 @@
|
|
15 | 13 |
} |
16 | 14 |
}; |
17 | 15 |
window.springfox = springfox; |
18 |
- window.oAuthRedirectUrl = springfox.baseUrl() + '/webjars/springfox-swagger-ui/o2c.html' |
|
16 |
- window.oAuthRedirectUrl = springfox.baseUrl() + '/webjars/springfox-swagger-ui/o2c.html';
|
|
19 | 17 |
- |
20 |
- $('#select_baseUrl').change(function() { |
|
21 |
- window.swaggerUi.headerView.trigger('update-swagger-ui', { |
|
22 |
- url: $('#select_baseUrl').val() |
|
23 |
- }); |
|
24 |
- }); |
|
25 | 18 |
+ window.oAuthRedirectUrl = springfox.baseUrl() + 'doc//webjars/springfox-swagger-ui/o2c.html' |
26 |
|
|
27 |
function maybePrefix(location, withRelativePath) { |
|
28 |
var pat = /^https?:\/\//i; |
|
29 |
@@ -32,6 +26,16 @@ $(function() { |
|
19 |
+ |
|
20 |
window.springfox.uiConfig(function(data) { |
|
21 |
window.swaggerUi = new SwaggerUi({ |
|
22 |
dom_id: "swagger-ui-container", |
|
23 |
@@ -98,6 +98,16 @@ |
|
24 |
} |
|
30 | 25 |
return withRelativePath + location; |
31 | 26 |
} |
27 |
+ |
|
32 | 28 |
+ function getUrlParam(key){ |
33 | 29 |
+ key = key.replace(/[*+?^$.\[\]{}()|\\\/]/g, "\\$&"); // escape RegEx meta chars |
34 | 30 |
+ var match = location.search.match(new RegExp("[?&]"+key+"=([^&]+)(&|$)")); |
35 | 31 |
+ return match && decodeURIComponent(match[1].replace(/\+/g, " ")); |
36 | 32 |
+ } |
37 |
+
|
|
33 |
+ |
|
38 | 34 |
+ function menuItemId(groupName){ |
39 | 35 |
+ return 'menu_' + groupName.replace(/\s/g, "_"); |
40 | 36 |
+ } |
41 |
+ |
|
42 |
$(document).ready(function() { |
|
43 |
|
|
44 |
var relativeLocation = springfox.baseUrl(); |
|
45 | 37 |
|
46 |
@@ -39,15 +43,29 @@ $(function() { |
|
38 |
function initializeBaseUrl() { |
|
39 |
var relativeLocation = springfox.baseUrl(); |
|
40 |
@@ -106,15 +116,28 @@ |
|
47 | 41 |
|
48 | 42 |
$.getJSON(relativeLocation + "/swagger-resources", function(data) { |
49 | 43 |
|
... | ... | |
56 | 50 |
- .attr("value", maybePrefix(resource.location, relativeLocation)) |
57 | 51 |
- .text(resource.name + " (" + resource.location + ")"); |
58 | 52 |
- $urlDropdown.append(option); |
59 |
+ // <li id="menu_Generic_REST_API"><a href="?group=Generic+REST+API">Generic REST API</a></li>
|
|
60 |
+ var id = menuItemId(resource.name); |
|
61 |
+ var link = $('<a></a>') |
|
62 |
+ .attr("href", maybePrefix(resource.location, relativeLocation)) |
|
63 |
+ .text(resource.name); |
|
64 |
+ var option = $('<li></li>').attr("id", id).append(link); |
|
65 |
+ $menulist.append(option); |
|
53 |
+ // example markup : <li id="menu_Generic_REST_API"><a href="?group=Generic+REST+API">Generic REST API</a></li>
|
|
54 |
+ var id = menuItemId(resource.name);
|
|
55 |
+ var link = $('<a></a>')
|
|
56 |
+ .attr("href", maybePrefix(resource.location, relativeLocation))
|
|
57 |
+ .text(resource.name);
|
|
58 |
+ var option = $('<li></li>').attr("id", id).append(link);
|
|
59 |
+ $menulist.append(option);
|
|
66 | 60 |
+ }); |
67 | 61 |
+ $('#select_baseUrl a').click(function(event) { |
68 |
+ event.preventDefault() |
|
69 |
+ window.swaggerUi.headerView.trigger( |
|
70 |
+ 'update-swagger-ui', |
|
71 |
+ {url: $(event.target).attr('href')} |
|
72 |
+ );
|
|
62 |
+ event.preventDefault()
|
|
63 |
+ window.swaggerUi.headerView.trigger(
|
|
64 |
+ 'update-swagger-ui',
|
|
65 |
+ {url: $(event.target).attr('href')}
|
|
66 |
+ );
|
|
73 | 67 |
}); |
74 | 68 |
- $urlDropdown.change(); |
75 |
+ |
|
76 | 69 |
+ var initialGroup = getUrlParam('group'); |
77 | 70 |
+ if(initialGroup) { |
78 |
+ $('#' + menuItemId(initialGroup) + " a").click();
|
|
71 |
+ $('#' + menuItemId(initialGroup) + " a").click(); |
|
79 | 72 |
+ } |
80 | 73 |
}); |
81 | 74 |
|
82 |
}); |
|
75 |
} |
Also available in: Unified diff
#7770 documenting springfox-swagger-ui update process