Skip to content

Commit

Permalink
remove else
Browse files Browse the repository at this point in the history
  • Loading branch information
TheJuanAndOnly99 committed Mar 7, 2024
1 parent 3d38f83 commit 44e0c66
Showing 1 changed file with 30 additions and 29 deletions.
59 changes: 30 additions & 29 deletions schema2Markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,44 @@ function processProperty(propertyName, propertyDetails, schemaExamples) {
if (propertyName === 'type') {
markdownContent += `### Type\n\n`;
markdownContent += `\`${propertyDetails.const}\`\n\n`;
} else {
markdownContent += `### ${propertyDetails.title || propertyName}\n\n`;
markdownContent += `\`${propertyName}\`\n\n`;
return markdownContent;
}
markdownContent += `### ${propertyDetails.title || propertyName}\n\n`;
markdownContent += `\`${propertyName}\`\n\n`;

if (propertyDetails.description != null) {
markdownContent += `${escape(propertyDetails.description)}\n\n`;
}
if (propertyDetails.description != null) {
markdownContent += `${escape(propertyDetails.description)}\n\n`;
}

if (propertyDetails.type) {
markdownContent += renderType(propertyDetails.type);
} else {
const contextRef = propertyDetails.properties?.context?.$ref || propertyDetails.$ref;
if (propertyDetails.type) {
markdownContent += renderType(propertyDetails.type);
} else {
const contextRef = propertyDetails.properties?.context?.$ref || propertyDetails.$ref;

if (contextRef) {
markdownContent += renderRef(contextRef);
}
if (contextRef) {
markdownContent += renderRef(contextRef);
}
}

if (propertyDetails.enum) {
markdownContent += renderEnum(propertyDetails.enum);
}
if (propertyDetails.enum) {
markdownContent += renderEnum(propertyDetails.enum);
}

if (propertyDetails.allOf) {
markdownContent += `${propertyDetails.allOf.map((item) => renderRef(item.$ref)).join(', ')}\n\n`;
}
if (propertyDetails.allOf) {
markdownContent += `${propertyDetails.allOf.map((item) => renderRef(item.$ref)).join(', ')}\n\n`;
}

if (schemaExamples) {
schemaExamples.forEach((example) => {
markdownContent += `**Example Value**: \n`;
if (typeof example[propertyName] === 'object') {
markdownContent += `\`\`\`json\n${JSON.stringify(example[propertyName], null, 2)}\n\`\`\`\n\n`;
} else if (example[propertyName]) {
markdownContent += `\`${example[propertyName]}\`\n\n`;
}
});
}
if (schemaExamples) {
schemaExamples.forEach((example) => {
markdownContent += `**Example Value**: \n`;
if (typeof example[propertyName] === 'object') {
markdownContent += `\`\`\`json\n${JSON.stringify(example[propertyName], null, 2)}\n\`\`\`\n\n`;
} else if (example[propertyName]) {
markdownContent += `\`${example[propertyName]}\`\n\n`;
}
});
}

return markdownContent;
}

Expand Down

0 comments on commit 44e0c66

Please sign in to comment.