MCPcopy
hub / github.com/github/docs / getDiffOpenAPIContentRest

Function getDiffOpenAPIContentRest

src/rest/scripts/test-open-api-schema.js:18–50  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

16const contentFiles = []
17
18export 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
52async function createOpenAPISchemasCheck() {
53 const schemasPath = path.join(process.cwd(), 'src/rest/data')

Callers 1

rest.jsFile · 0.90

Calls 4

throughDirectoryFunction · 0.85
getDifferencesFunction · 0.85

Tested by

no test coverage detected