Skip to content

Commit

Permalink
rendering out sub properties
Browse files Browse the repository at this point in the history
  • Loading branch information
maoo committed Apr 11, 2024
1 parent 490af28 commit f74e8b0
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion schema2Markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function processProperty(propertyName, propertyDetails, schemaExamples, required
//skip rendering the type property as it should be rendered at the top level
return markdownContent;
}
markdownContent += `### \`${propertyName}\`}\n\n`;
markdownContent += `### \`${propertyName}\`\n\n`;
if (required) { markdownContent += `**(required)**\n`; }

if (propertyDetails.description != null) {
Expand All @@ -34,6 +34,17 @@ function processProperty(propertyName, propertyDetails, schemaExamples, required
markdownContent += `${propertyDetails.allOf.map((item) => renderRef(item.$ref)).join(', ')}\n\n`;
}


if (propertyDetails.properties && Object.entries(propertyDetails.properties).length > 0) {
// console.log("Sub props for "+propertyName+" - ",propertyDetails.properties.entries())
markdownContent += '#### Subproperties\n';
for (const [subpropertyName, subpropertyDetails] of Object.entries(propertyDetails.properties)) {
markdownContent += `Name: \`${subpropertyName}\`\n`;
markdownContent += `Type: \`${subpropertyDetails.type}\`\n`;
markdownContent += `Description: \`${subpropertyDetails.description}\`\n\n`;
};
}

if (schemaExamples) {
schemaExamples.forEach((example) => {
markdownContent += `**Example Value**: \n`;
Expand Down

0 comments on commit f74e8b0

Please sign in to comment.