-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
172 lines (166 loc) · 6.88 KB
/
index.html
File metadata and controls
172 lines (166 loc) · 6.88 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>iSHARE API Documentation</title>
<link rel="icon" type="image/avif" href="ishare.avif">
<link rel="stylesheet" type="text/css" href="https://unpkg.com/swagger-ui-dist@5.11.0/swagger-ui.css">
<style>
body {
margin: 0;
padding: 0;
}
#header {
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 1000;
background: #1b1b1b;
padding: 20px 20px;
text-align: left;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
font-size: 14px;
color: #fff;
border-bottom: 1px solid #41444e;
}
#header a {
color: #4990e2;
text-decoration: none;
}
#header a:hover {
text-decoration: underline;
}
#version-selector {
position: fixed;
top: 0;
right: 0;
z-index: 1001;
padding: 14px 20px;
background: #1b1b1b;
color: #fff;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
font-size: 14px;
display: flex;
align-items: center;
border-bottom-left-radius: 4px;
}
#version-selector label {
margin-right: 10px;
color: #fff;
}
#version-selector select {
padding: 6px 10px;
border: 1px solid #41444e;
border-radius: 4px;
background-color: #2b2b2b;
color: #fff;
font-size: 14px;
cursor: pointer;
outline: none;
transition: border-color 0.2s;
}
#version-selector select:hover {
border-color: #4990e2;
}
#version-selector select:focus {
border-color: #4990e2;
box-shadow: 0 0 0 2px rgba(73, 144, 226, 0.2);
}
#version-selector select option {
background-color: #2b2b2b;
color: #fff;
}
/* Add margin to the swagger-ui container to account for the header */
#swagger-ui {
margin-top: 70px;
}
</style>
</head>
<body>
<div id="header">
This page is part of the iSHARE Framework and must be seen as an extension of the <a href="https://dev.ishare.eu/introduction/getting-started/openapi-descriptions" target="_blank">iSHARE Developer Portal</a>.
</div>
<div id="version-selector">
<label for="version">API Version:</label>
<select id="version" onchange="changeVersion()">
<option value="3.0 (DCP)">Current Version (3.0) DCP Endpoints</option>
<option value="3.0">Current Version (3.0)</option>
<option value="2.2">2.2</option>
<option value="2.1.1">2.1.1</option>
<option value="2.1">2.1</option>
<option value="2.0">2.0(.1)</option>
<!-- Add more versions as needed -->
</select>
</div>
<div id="swagger-ui"></div>
<script src="https://unpkg.com/swagger-ui-dist@5.11.0/swagger-ui-bundle.js"></script>
<script src="https://unpkg.com/swagger-ui-dist@5.11.0/swagger-ui-standalone-preset.js"></script>
<script>
const versions = {
'3.0 (DCP)': 'https://raw.githubusercontent.com/iSHAREScheme/openapi/v3.0/ishare_openapi_spec_dcp.yaml',
'3.0': 'https://raw.githubusercontent.com/iSHAREScheme/openapi/v3.0/ishare_openapi_spec.yaml',
'2.2': 'https://raw.githubusercontent.com/iSHAREScheme/openapi/v2.2/ishare_openapi_spec.yaml',
'2.1.1': 'https://raw.githubusercontent.com/iSHAREScheme/openapi/v2.1.1/ishare_openapi_spec.yaml',
'2.1': 'https://raw.githubusercontent.com/iSHAREScheme/openapi/v2.1/ishare_openapi_spec.yaml',
'2.0': 'https://raw.githubusercontent.com/iSHAREScheme/openapi/v2.0/ishare_openapi_spec.yaml'
};
// Get URL parameters and tag
const urlParams = new URLSearchParams(window.location.search);
const versionParam = urlParams.get('version');
const tag = window.location.hash.substring(1); // Remove the # character
function initSwaggerUI(url) {
window.ui = SwaggerUIBundle({
url: url,
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis
],
onComplete: function() {
if (tag) {
// Handle SwaggerHub-style deep linking
const operationTag = tag.split('/').pop(); // Get the last part of the tag
// Find the element by data-name attribute
const element = document.querySelector(`[data-name="${operationTag}"]`);
if (element) {
// Find and click the expand button
const expandButton = element.querySelector('.model-box-control');
if (expandButton) {
expandButton.click();
// Scroll the element into view with smooth behavior
element.scrollIntoView({ behavior: 'smooth', block: 'center' });
}
} else if (spec && spec.paths) {
// If it's a path, find and expand it
Object.entries(spec.paths).forEach(([pathKey, pathObj]) => {
Object.entries(pathObj).forEach(([method, operation]) => {
if (operation.operationId === operationTag) {
window.ui.actions.show(pathKey, method);
}
});
});
}
}
}
});
}
function changeVersion() {
const version = document.getElementById('version').value;
const url = versions[version];
if (url) {
// Update URL with new version
const newUrl = new URL(window.location.href);
newUrl.searchParams.set('version', version);
window.history.pushState({}, '', newUrl);
initSwaggerUI(url);
}
}
// Initialize with version from URL or default to v3.0
const initialVersion = versionParam || '3.0';
document.getElementById('version').value = initialVersion;
initSwaggerUI(versions[initialVersion]);
</script>
</body>
</html>