Skip to content

Commit

Permalink
add a link to the json.schema file, fix parsing of versions
Browse files Browse the repository at this point in the history
  • Loading branch information
TheJuanAndOnly99 committed Mar 7, 2024
1 parent 6bf17da commit 3d38f83
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions schema2Markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function hasProperties(schema) {
}

// Function to generate Markdown content from JSON schema
function generateObjectMD(schema, title, schemaFolderName, version) {
function generateObjectMD(schema, title, schemaFolderName, filePath, version) {

const objectName = schema.title

Expand Down Expand Up @@ -150,6 +150,8 @@ function generateObjectMD(schema, title, schemaFolderName, version) {
markdownContent += JSON.stringify(schema.examples, null, 2);
markdownContent += '\n```';
}
const url = filePath.replace("schemas/", `https://github.com/finos/FDC3/tree/master/schemas/`);
markdownContent += `Generated from ${url}`;
}

const frontMatter = generateFrontMatter(objectName, schema.description);
Expand Down Expand Up @@ -186,11 +188,11 @@ function processSchemaFile(schemaFile, schemaFolderName, version) {
const allOfArray = schemaData.allOf;
let sidebarItems = [];
if (Array.isArray(allOfArray) && allOfArray.length > 0) {
sidebarItems.push(generateObjectMD(schemaData, null, schemaFolderName, version));
sidebarItems.push(generateObjectMD(schemaData, null, schemaFolderName, schemaFile, version));
}
if (schemaData.definitions) {
for (const [objectName, objectDetails] of Object.entries(schemaData.definitions)) {
sidebarItems.push(generateObjectMD(objectDetails, objectName, schemaFolderName, version));
sidebarItems.push(generateObjectMD(objectDetails, objectName, schemaFolderName, schemaFile, version));
}
}

Expand Down

0 comments on commit 3d38f83

Please sign in to comment.