()
| 16 | const contentFiles = [] |
| 17 | |
| 18 | export async function getDiffOpenAPIContentRest() { |
| 19 | const contentPath = path.join(process.cwd(), 'content/rest') |
| 20 | |
| 21 | // Recursively go through the content/rest directory and add all categories/subcategories to contentFiles |
| 22 | throughDirectory(contentPath) |
| 23 | |
| 24 | // Creating the categories/subcategories based on the current content directory |
| 25 | const checkContentDir = await createCheckContentDirectory(contentFiles) |
| 26 | |
| 27 | // Create categories/subcategories from OpenAPI Schemas |
| 28 | const openAPISchemaCheck = await createOpenAPISchemasCheck() |
| 29 | |
| 30 | // Get Differences between categories/subcategories from dereferenced schemas and the content/rest directory frontmatter versions |
| 31 | const differences = getDifferences(openAPISchemaCheck, checkContentDir) |
| 32 | const errorMessages = {} |
| 33 | |
| 34 | if (Object.keys(differences).length > 0) { |
| 35 | for (const schemaName in differences) { |
| 36 | errorMessages[schemaName] = {} |
| 37 | |
| 38 | differences[schemaName].forEach((category) => { |
| 39 | if (!errorMessages[schemaName]) errorMessages[schemaName] = category |
| 40 | |
| 41 | errorMessages[schemaName][category] = { |
| 42 | contentDir: checkContentDir[schemaName][category], |
| 43 | openAPI: openAPISchemaCheck[schemaName][category], |
| 44 | } |
| 45 | }) |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | return errorMessages |
| 50 | } |
| 51 | |
| 52 | async function createOpenAPISchemasCheck() { |
| 53 | const schemasPath = path.join(process.cwd(), 'src/rest/data') |
no test coverage detected