-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdocs.html
207 lines (176 loc) · 8.95 KB
/
docs.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<!DOCTYPE html>
<html>
<head>
<title>Swagger UI</title>
<link rel="icon" type="image/png" href="/docs/static/images/favicon-32x32.png" sizes="32x32"/>
<link rel="icon" type="image/png" href="/docs/static/images/favicon-16x16.png" sizes="16x16"/>
<link href='./docs/static/css/typography.css' media='screen' rel='stylesheet' type='text/css'/>
<link href='./docs/static/css/reset.css' media='screen' rel='stylesheet' type='text/css'/>
<link href='./docs/static/css/screen.css' media='screen' rel='stylesheet' type='text/css'/>
<link href='./docs/static/css/reset.css' media='print' rel='stylesheet' type='text/css'/>
<link href='./docs/static/css/print.css' media='print' rel='stylesheet' type='text/css'/>
<script src='./docs/static/lib/jquery-1.8.0.min.js' type='text/javascript'></script>
<script src='./docs/static/lib/jquery.slideto.min.js' type='text/javascript'></script>
<script src='./docs/static/lib/jquery.wiggle.min.js' type='text/javascript'></script>
<script src='./docs/static/lib/jquery.ba-bbq.min.js' type='text/javascript'></script>
<script src='./docs/static/lib/handlebars-2.0.0.js' type='text/javascript'></script>
<script src='./docs/static/lib/underscore-min.js' type='text/javascript'></script>
<script src='./docs/static/lib/backbone-min.js' type='text/javascript'></script>
<script src='./docs/static/swagger-ui.min.js' type='text/javascript'></script>
<script src='./docs/static/lib/highlight.7.3.pack.js' type='text/javascript'></script>
<script src='./docs/static/lib/marked.js' type='text/javascript'></script>
<script src='./docs/static/lib/swagger-oauth.js' type='text/javascript'></script>
<script type="text/javascript">
$(function () {
var API_DOCS_PREFIX = "/api-docs/";
var API_DOCS_POSTFIX = "?group=public";
var API_QUERY_PARAMETER = "api";
var PLATFORM_HOST = "https://platformdev.cloud.coveo.com";
var TEST_EXTENSION = "";
var TESTING_LOCALLY = false; // Set to `true` to generate site from local/custom Swagger files.
var TEST_CUSTOM_PATH = ""; // Example: `/fbeaudoincoveo/swaggerUI_withQ/tree/master/api-docs-tests/`.
var TEST_CUSTOM_HOST = ""; // Example: `https://github.com`.
if (TESTING_LOCALLY)
{
API_DOCS_PREFIX = TEST_CUSTOM_PATH ?
TEST_CUSTOM_PATH :
"/api-docs-tests/";
API_DOCS_POSTFIX = "";
if (TEST_CUSTOM_HOST) {
PLATFORM_HOST = TEST_CUSTOM_HOST
}
else {
var temp = window.location.pathname.split("/");
temp.pop();
PLATFORM_HOST = temp.join("/");
}
TEST_EXTENSION = ".json"
}
function addApi(label, value) {
if (value.length > API_DOCS_PREFIX.length) {
$('#api_list').append('<option value="' + value + '">' + label + '</option>');
}
}
addApi('Platform', PLATFORM_HOST + API_DOCS_PREFIX + 'Platform' + TEST_EXTENSION);
addApi('Index', PLATFORM_HOST + API_DOCS_PREFIX + 'Index' + TEST_EXTENSION);
addApi('Security Cache', PLATFORM_HOST + API_DOCS_PREFIX + 'SecurityCache' + TEST_EXTENSION);
addApi('Source', PLATFORM_HOST + API_DOCS_PREFIX + 'Source' + TEST_EXTENSION);
addApi('Activity', PLATFORM_HOST + API_DOCS_PREFIX + 'Activity' + TEST_EXTENSION);
addApi('Privilege', PLATFORM_HOST + API_DOCS_PREFIX + 'Privilege' + TEST_EXTENSION);
addApi('Usage Analytics', PLATFORM_HOST + API_DOCS_PREFIX + 'UsageAnalytics' + TEST_EXTENSION);
addApi('Push', PLATFORM_HOST + API_DOCS_PREFIX + 'PushApi' + TEST_EXTENSION);
addApi('Extension', PLATFORM_HOST + API_DOCS_PREFIX + 'Extension' + TEST_EXTENSION);
/**
* Parses the URL query string and returns the corresponding parameter value if able.
* @param {string} parameter The query parameter whose value should be retrieved from the URL query string.
* @returns {*} The parameter value, or `undefined` if parameter was not found in the URL query string.
*/
function getURLQueryParameterValue(parameter) {
return document.location.search.includes(parameter) ?
document.location.search.split(parameter + "=").pop().split("&").shift() :
undefined;
}
$('#api_list').val(PLATFORM_HOST + API_DOCS_PREFIX + getURLQueryParameterValue(API_QUERY_PARAMETER));
window.swaggerUi = new SwaggerUi({
url: $('#api_list').val(),
dom_id: "swagger-ui-container",
supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
onComplete: function (swaggerApi, swaggerUi) {
// Temporarily patches the problem with anchors in the Usage Analytics API.
// This patch is not very robust, as it heavily depends on resource/tag naming format.
// The patch will work as long as the resource/tag names match /\w\/\w(\/)?
// The best solution would be to fix the resource names in the Swagger, by eliminating all "/" from
// resource names and associated tags.
// This solution also does not scroll very beautifully to anchors in the page.
if ($('#api_list').val().split("/").pop() == !TESTING_LOCALLY && 'UsageAnalytics') {
document.querySelectorAll("a.toggleOperation").forEach(function(element) {
element.href = element.hash.split("%2F").join("/").split("//").join("/");
});
if (document.location.hash) {
var temp = document.location.hash.split("/");
temp.pop();
temp.shift();
var resourceId = temp.join("/");
temp = $('a.collapseResource[href="#"][data-id="' + resourceId + '"]');
var resource = temp.length > 0 ?
temp :
$('a.collapseResource[href="#"][data-id="' + resourceId.split("/").concat("").join("/") + '"]');
resource.click();
var operation = $('ul.options li a.toggleOperation[href="' + document.location.hash + '"]');
operation.click();
setTimeout(function() {
$(window).scrollTop(operation.parents('div.heading').offset().top);
}, 500)
}
}
console.log("Loaded SwaggerUI");
if (typeof initOAuth == "function") {
initOAuth({
clientId: "Swagger",
realm: "Platform",
appName: "Coveo Cloud Platform"
});
}
},
onFailure: function (data) {
console.log("Unable to Load SwaggerUI");
},
docExpansion: "none",
apisSorter: function (a, b) {
if (a.name.indexOf("/") !== -1 && b.name.indexOf("/") !== -1) {
var id1 = a.name.split("/");
var id2 = b.name.split("/");
// Sort by version in descending alphabetical order
// Followed by sort by resource ascending alphabetical order
if (id1[0] < id2[0]) return 1;
if (id1[0] > id2[0]) return -1;
if (id1[1] < id2[1]) return -1;
if (id1[1] > id2[1]) return 1;
return 0;
} else {
return a.name.localeCompare(b.name);
}
},
showRequestHeaders: false,
validatorUrl: null
});
/**
* Replaces the state by appending the API_DOCS_POSTFIX as well as the &api=apiName condition to the URL query
* string.
* @param apiName The name of the currently selected API.
*/
function replaceURL(apiName) {
if (TESTING_LOCALLY) {
history.replaceState("", "", API_DOCS_POSTFIX + "?" + API_QUERY_PARAMETER + "=" + apiName);
}
else {
history.replaceState("", "", API_DOCS_POSTFIX + "&" + API_QUERY_PARAMETER + "=" + apiName);
}
}
window.swaggerUi.load();
// After swaggerUI has loaded, replace the state to reflect the current API and display the correct anchor.
replaceURL($('#api_list').val().split("/").pop() + document.location.hash);
// When selected API changes, update URL accordingly.
$('#api_list').change(function () {
window.swaggerUi.updateSwaggerUi({url: this.value});
replaceURL(this.value.split('/').pop());
});
});
</script>
</head>
<body class="swagger-section">
<div id='header'>
<div class="swagger-ui-wrap">
<a id="logo" href="http://www.coveo.com">Coveo Cloud Platform API</a>
<form id='api_selector'>
<div class='input'>
<select id='api_list' name='api_list'>
</select>
</div>
</form>
</div>
</div>
<div id="message-bar" class="swagger-ui-wrap"> </div>
<div id="swagger-ui-container" class="swagger-ui-wrap"></div>
</body>
</html>