-
-
Notifications
You must be signed in to change notification settings - Fork 170
/
index.html
203 lines (184 loc) · 7.47 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
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
<!doctype html>
<html lang="en" class="has-navbar-fixed-top">
<head>
<title>OpenAPI-GUI v3.0.0</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf8">
<link href="css/font-awesome.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/styles/github.min.css">
<link href="css/buefy.min.css" rel="stylesheet">
<link href="css/balloon.min.css" rel="stylesheet">
<link href="css/jsoneditor.min.css" rel="stylesheet" type="text/css">
<link href="css/app.css" rel="stylesheet">
<script type='text/javascript' src='js/jquery.min.js'></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/1.5.5/clipboard.min.js"></script>
<script type='text/javascript' src="js/highlight.min.js"></script>
<script type='text/javascript' src="js/js-yaml.min.js"></script>
<script type='text/javascript' src="js/jsonpatch.js"></script>
<script type='text/javascript' src="js/jsoneditor.min.js"></script>
<script type='text/javascript' src="data/static.js"></script>
<script type='text/javascript' src="js/vue.min.js"></script>
<script type='text/javascript' src="js/vuelidate.min.js"></script>
<script type='text/javascript' src="js/validators.min.js"></script>
<script type='text/javascript' src="js/buefy.min.js"></script>
<script type='text/javascript' src="js/markdown-it.min.js"></script>
<script src="src/resource/resource.js"></script>
<script src="src/method/method.js"></script>
<script src="src/parameter/parameter.js"></script>
<script src="src/items/items.js"></script>
<script src="src/app/gui.js"></script>
<script src="src/api-definition/api-definition.js"></script>
<script src="src/api-yaml/api-yaml.js"></script>
<script src="src/app/app.js"></script>
</head>
<body>
<div id="loading" class="section">
<div class="container is-fluid">
<article class="message">
<div class="message-header">
<p>Loading</p>
<button class="delete"></button>
</div>
<div class="message-body">
<strong>Please wait!</strong> OpenAPI-GUI v3 is loading... <progress id="progress" class="progress is-success" value="0" max="100">0 %</progress>
<p>In case OpenAPI-GUI does not start, please use the <a href="/rescue.html">rescue utility</a>.</p>
</div>
</article>
</div>
</div>
<div id="main-container">
<gui-main :openapi='container.openapi' :importschema='importschema'></gui-main>
</div>
<script>
var def = [];
var cgData = {
clients : [],
servers : []
};
window.intelligentBackend = false;
function resolveDef(index) {
$('#progress').attr('value', parseInt($('#progress').attr('value'))+16.66);
def[index].resolve();
}
var zoom_level=100;
function zoom_page(step) {
// Zoom by steps in or out
if (zoom_level>=120 && step>0 || zoom_level<=80 && step<0) return;
// Set / reset zoom
if (step==0) zoom_level=100;
else zoom_level=zoom_level+step;
// Set page zoom via CSS
$('html').css({
transform: 'scale('+(zoom_level/100)+')', // set zoom
transformOrigin: '50% 0' // set transform scale base
});
// Adjust page to zoom width
if (zoom_level>100) $('body').css({ width: (zoom_level*1.2)+'%' });
else $('html').css({ width: '100%' });
}
$(document).ready(function(){
$.ajax('https://api.openapi-generator.tech/api/gen/clients',{
success: function(data) {
cgData.clients = data;
}
});
$.ajax('https://api.openapi-generator.tech/api/gen/servers',{
success: function(data) {
cgData.servers = data;
}
});
// Create the Deferred instances that can be handed to $.when()
for (t=0;t<8;t++) {
def.push($.Deferred());
}
// Set up the chain of events...
$.when(def[0], def[1], def[2], def[3], def[4], def[5], def[6], def[7]).then(function() {
if (screen && screen.orientation) {
try {
screen.orientation.lock('landscape');
}
catch (ex) {};
}
$(function() { $.support.transition = false; });
app_main();
if ($(window).width()<1920) zoom_page(-14.0);
$('#loading').hide();
});
// And finally: Make the actual ajax calls:
$('#template-gui-main').load('src/app/gui.html', function(data,status,jqXHR) {
if (jqXHR.getResponseHeader('X-OpenAPI-GUI')) {
window.intelligentBackend = true;
}
resolveDef(0); });
$('#template-resource').load('src/resource/resource.html', function() { resolveDef(1); });
$('#template-method').load('src/method/method.html', function() { resolveDef(2); });
$('#template-parameter').load('src/parameter/parameter.html', function() { resolveDef(3); });
$('#template-definition').load('src/api-definition/output.html', function() { resolveDef(4); });
$('#template-yaml').load('src/api-yaml/output.html', function() { resolveDef(5); });
$('#template-items').load('src/items/items.html', function() { resolveDef(6); });
// def(7) is our chance to load a spec from a querystring parameter
var loadUrl = getParameterByName('url');
var resolveNow = true;
if (loadUrl) {
$.ajax(loadUrl,{
success: function(data) {
try {
if (typeof data === 'string') {
data = jsyaml.safeLoad(data);
}
if (data.swagger && (data.swagger === '2.0')) {
resolveNow = false;
convertOpenApi2(data,function(schema){
openapi = preProcessDefinition(schema);
resolveDef(7);
});
}
else {
openapi = preProcessDefinition(data);
}
}
catch (ex) {
alert(ex);
}
},
complete: function() {
if (resolveNow) resolveDef(7);
}
});
}
else {
resolveDef(7);
}
});
</script>
<div class="hidden">
<div id="template-gui-main"></div>
<div id="template-resource"></div>
<div id="template-method"></div>
<div id="template-parameter"></div>
<div id="template-definition"></div>
<div id="template-yaml"></div>
<div id="template-items"></div>
</div>
<div class="modal fade" id="schemaModal">
<div class="card" id="schemaModalCard">
<div class="card-header">
<!--<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>-->
<h3 class="title" id="schemaModalTitle">Schema Editor</h3>
</div>
<div class="card-content">
<div id="schemaContainer">
</div>
</div>
<div class="card-footer">
<p class="card-footer-item">
<a href="#" class="button is-warning" onclick="schemaEditorClose()">Close</a>
</p>
<p class="card-footer-item">
<a href="#" class="button is-primary" onclick="schemaEditorSave()">Save changes</a>
</p>
</div>
</div>
</div>
</body>
</html>