mirror of
https://github.com/LukeHagar/SwagDefGen.git
synced 2025-12-06 04:21:38 +00:00
76 lines
2.1 KiB
HTML
76 lines
2.1 KiB
HTML
<!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>
|