-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathdocumentation.html
47 lines (42 loc) · 1.69 KB
/
documentation.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
{% cdn_asset /swagger-ui/2.2.10/swagger-ui.js %}
{% cdn_asset /swagger-ui/2.2.10/swagger-ui.css %}
{% include 'shared/swagger_ui' %}
<div class="api-list-container" style="display: none;">
<h1>API Catalog</h1>
<p>List of all available APIs:</p>
<ul class="api-list">
</ul>
</div>
<script type="text/javascript">
var services = {
{% assign items = provider.services |map: "system_name" %}
{% for system_name in items %}
{% if provider.api_specs[system_name] %}
"{{ system_name }}": {
name: "{{ provider.services[system_name].name|url_encode }}",
url: "{{ provider.api_specs[system_name].url }}",
description: "{{ provider.services[system_name].description|url_encode }}"
},
{% endif %}
{% endfor %}
};
$( document ).ready(function() {
var searchParams = new URLSearchParams(window.parent.location.search) ;
if (searchParams.has("api")) {
var api = searchParams.get("api");
$(".api-list-container").css("display", "none");
window.swaggerUi.options['url'] = services[api].url;
window.swaggerUi.load();
} else {
$(".api-list-container").css("display", "block");
var system_names = Object.keys(services).sort();
for (var i = 0; i < system_names.length; i++) {
var name = system_names[i]; // system_name
if (services[system_names[i]].name != null) { // if present, name is a better option
name = decodeURIComponent(services[system_names[i]].name.replace(/\+/g, '%20')) + ": " + decodeURIComponent(services[system_names[i]].description.replace(/\+/g, '%20'));
}
$("<a>", { "href": "?api=" + system_names[i], text: name }).appendTo($("<li>").appendTo($(".api-list")));
}
}
});
</script>