mirror of
https://github.com/LukeHagar/SwagDefGen.git
synced 2025-12-07 04:21:40 +00:00
Update swaggerGen.js
This commit is contained in:
@@ -117,9 +117,11 @@ function convert() {
|
|||||||
-outSwagger
|
-outSwagger
|
||||||
*/
|
*/
|
||||||
let schema = {};
|
let schema = {};
|
||||||
|
let examples = new Set();
|
||||||
for (const entry of obj) {
|
for (const entry of obj) {
|
||||||
for (const key of Object.keys(entry)) {
|
for (const key of Object.keys(entry)) {
|
||||||
if (!Object.keys(schema).includes(key)) {
|
if (!Object.keys(schema).includes(key)) {
|
||||||
|
examples.add(entry);
|
||||||
schema[key] = entry[key];
|
schema[key] = entry[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -131,6 +133,15 @@ function convert() {
|
|||||||
conversorSelection(schema);
|
conversorSelection(schema);
|
||||||
outSwagger += indentator + "}";
|
outSwagger += indentator + "}";
|
||||||
// ---- End items scope ----
|
// ---- End items scope ----
|
||||||
|
// ---- Begin example scope ----
|
||||||
|
if (document.getElementById("requestExamples").checked) {
|
||||||
|
console.log(examples);
|
||||||
|
outSwagger +=
|
||||||
|
"," +
|
||||||
|
indentator +
|
||||||
|
'"example": ' +
|
||||||
|
JSON.stringify(Array.from(examples), null, "\t");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function convertObject(obj) {
|
function convertObject(obj) {
|
||||||
|
|||||||
Reference in New Issue
Block a user