From 1950f733b472ab56133fd0f4250c46c74ff37a9f Mon Sep 17 00:00:00 2001 From: Juan Estrella Date: Thu, 11 Apr 2024 11:10:41 +0200 Subject: [PATCH] remove api schemas and render type at top level and skip under properties section --- schema2Markdown.js | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/schema2Markdown.js b/schema2Markdown.js index f51746cba..563e2846e 100644 --- a/schema2Markdown.js +++ b/schema2Markdown.js @@ -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) { @@ -118,16 +118,19 @@ function generateObjectMD(schema, title, schemaFolderName, filePath, version) { } const properties = root.properties; - const required = root.required; + const typeString = properties?.type?.const; const ref = root.$ref; - + + markdownContent += `## Type\n\n`; + markdownContent += `\`${typeString}\`\n\n`; markdownContent += `## Properties\n\n`; for (const [propertyName, propertyDetails] of Object.entries(properties)) { - markdownContent += processProperty(propertyName, propertyDetails, schema.examples, required.includes(propertyName)); + if (propertyName != "type"){ + markdownContent += processProperty(propertyName, propertyDetails, schema.examples); + } } - if (ref) { markdownContent += `ref: ${ref}\n\n`; } @@ -163,7 +166,7 @@ function generateObjectMD(schema, title, schemaFolderName, filePath, version) { } function escape(text) { - return text.replace(/>/g, '\\>').replace(/@experimental/g, '[@experiemental](/docs/fdc3-compliance#experimental-features)'; + return text.replace(/>/g, '\\>').replace(/@experimental/g, '[@experiemental](/docs/fdc3-compliance#experimental-features)'); } function generateFrontMatter(title, description) { @@ -222,14 +225,6 @@ function main() { "items": [] } - let sidebarApiObject = { - "type": "category", - "label": "API Schemas Part", - "items": [] - } - - sidebarContextObject.items = parseSchemaFolder('context', version); - if (sidebarObject.docs["FDC3 Standard"] == null) { sidebarObject.docs["FDC3 Standard"] = []; }