mirror of
https://github.com/LukeHagar/SwagDefGen.git
synced 2025-12-06 04:21:38 +00:00
Add option to generate YAML
This commit is contained in:
@@ -66,6 +66,7 @@
|
||||
<option value="boolean">Boolean</option>
|
||||
</select>
|
||||
</p>
|
||||
<p>Genreate YAML: <input type="checkbox" id="YAML"></p>
|
||||
<hr>
|
||||
<p>Feel like colaborating? Clone the repository at <a target="_blank" href="https://github.com/Roger13/SwaggerGenerator">GitHub</a></p>
|
||||
|
||||
|
||||
@@ -149,6 +149,14 @@ function convert() {
|
||||
}
|
||||
};
|
||||
|
||||
function format(value, yaml) {
|
||||
if (yaml) {
|
||||
return value.replace(/[{},"]+/g, '').replace(/\t/g, ' ').replace(/(^[ \t]*\n)/gm, "");
|
||||
} else {
|
||||
return value
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Execution begins here ----
|
||||
inJSON = document.getElementById("JSON").value;
|
||||
try {
|
||||
@@ -178,5 +186,6 @@ function convert() {
|
||||
changeIndentation(tabCount-1);
|
||||
outSwagger += indentator + '}';
|
||||
|
||||
document.getElementById("Swagger").value = outSwagger;
|
||||
var yaml = document.getElementById("YAML").checked;
|
||||
document.getElementById("Swagger").value = format(outSwagger, yaml);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user