forked from Roger13/SwagDefGen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
75 lines (72 loc) · 2.13 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<title>Swagger Generator</title>
<script src="swaggerGen.js" type="text/javascript"></script>
<script>
function init() {
//Handle tabs inside JSON textarea
let txtArea = document.getElementById('JSON');
txtArea.onkeydown = function(e){
if(e.keyCode==9 || e.which==9){
e.preventDefault();
let s = this.selectionStart;
this.value = this.value.substring(0,this.selectionStart) + "\t" + this.value.substring(this.selectionEnd);
this.selectionEnd = s+1;
}
}
};
</script>
<style>
textarea{
display: inline-block;
margin: 10px;
}
button{
display: inline-block;
}
</style>
</head>
<body onload="init();">
<h1>Swagger Definition Objects Generator</h1>
<p>Add your JSON mock to generate Swagger definition objects.</p>
<textarea id="JSON" rows="20" cols="55" placeholder="Type your JSON">
{
"numbersMock": {
"smallInt": -20,
"bigInt": 2147483647,
"unsafeInt": 9999999999999999,
"notInt": 12.2
},
"stringsMock": {
"stringTest": "Hello World",
"isoDate": "1999-12-31",
"isoDateTime": "1999-12-31T23:59:59Z"
},
"objectsMock": {
"child": {"child": true},
"childList": [{"child": true}],
"childMatrix": [[{"child": true}]],
"nullable": null
}
}
</textarea>
<button type="button" onclick="convert()">Convert</button>
<textarea readonly id="Swagger" rows="20" cols="85" placeholder="Here is your Swagger"></textarea>
<br>
<p>Add values as examples: <input type="checkbox" id="requestExamples"></p>
<p>Convert integer values to number: <input type="checkbox" id="noInt"></p>
<p>Convert null values to:
<select id="nullType">
<option value="string" selected="">String</option>
<option value="number">Number</option>
<option value="integer">Integer</option>
<option value="boolean">Boolean</option>
</select>
</p>
<p>Output as YAML: <input type="checkbox" id="yamlOut"></p>
<hr>
<p>Feel like collaborating? Clone the repository at <a target="_blank" href="https://github.com/Roger13/SwaggerGenerator">GitHub</a></p>
</body>
</html>