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>
|
<option value="boolean">Boolean</option>
|
||||||
</select>
|
</select>
|
||||||
</p>
|
</p>
|
||||||
|
<p>Genreate YAML: <input type="checkbox" id="YAML"></p>
|
||||||
<hr>
|
<hr>
|
||||||
<p>Feel like colaborating? Clone the repository at <a target="_blank" href="https://github.com/Roger13/SwaggerGenerator">GitHub</a></p>
|
<p>Feel like colaborating? Clone the repository at <a target="_blank" href="https://github.com/Roger13/SwaggerGenerator">GitHub</a></p>
|
||||||
|
|
||||||
|
|||||||
@@ -148,6 +148,14 @@ function convert() {
|
|||||||
outSwagger += ' }';
|
outSwagger += ' }';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function format(value, yaml) {
|
||||||
|
if (yaml) {
|
||||||
|
return value.replace(/[{},"]+/g, '').replace(/\t/g, ' ').replace(/(^[ \t]*\n)/gm, "");
|
||||||
|
} else {
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ---- Execution begins here ----
|
// ---- Execution begins here ----
|
||||||
inJSON = document.getElementById("JSON").value;
|
inJSON = document.getElementById("JSON").value;
|
||||||
@@ -178,5 +186,6 @@ function convert() {
|
|||||||
changeIndentation(tabCount-1);
|
changeIndentation(tabCount-1);
|
||||||
outSwagger += indentator + '}';
|
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