This repository has been archived by the owner on Oct 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.html
93 lines (80 loc) · 4.06 KB
/
index.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
<html>
<head>
<script src="https://unpkg.com/swagger-ui-dist@3/swagger-ui-bundle.js"></script>
<link rel="stylesheet" type="text/css" href="https://unpkg.com/swagger-ui-dist@3/swagger-ui.css"/>
<title>My New API</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap-select.min.css">
<!-- Latest compiled and minified JavaScript -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap-select.min.js"></script>
<body>
<select class="selectpicker form-control form-control-lg" data-live-search="true" id="select-branch" style="margin-bottom: 15px" onchange="reload()">
</select>
<div>
<button style="width: 50%; float:left" type="button" class="btn btn-primary btn-lg" onclick="web()"> WEB </button>
<button style="width: 50%; float:left" type="button" class="btn btn-secondary btn-lg" onclick="app()"> APP </button>
<br style="clear:both;"/>
</div>
<div id="swagger-ui"></div>
<script>
$('select-branch').selectpicker();
var branch="main";
function reload(){
branch = document.getElementById("select-branch").value;
app();
web();
}
async function fillBranches(){
const response = await fetch("https://api.github.com/repos/PTIN2022/A2/branches?per_page=10000&page=1")
var options = await response.json();
for(var i = 0; i < options.length; i++) {
var opt = options[i]["name"];
$("#select-branch").append('<option value="'+opt+'" selected="">'+opt+'</option>');
}
$("#select-branch").val("main");
$("#select-branch").selectpicker("refresh");
};
fillBranches();
function web () {
const ui = SwaggerUIBundle({
url: "https://raw.githubusercontent.com/PTIN2022/A2/"+branch+"/API/api-gestion.yml",
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIBundle.SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
})
window.ui = ui
}
function app () {
const ui = SwaggerUIBundle({
url: "https://raw.githubusercontent.com/PTIN2022/A2/"+branch+"/API/api-app.yml",
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIBundle.SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
})
window.ui = ui
}
window.onload = web();
</script>
</body>
<style>
body {
margin-top:10px
}
</style>
</html>