MCPcopy
hub / github.com/github/docs / getOpenApiSchemaFiles

Function getOpenApiSchemaFiles

src/rest/scripts/utils/decorator.js:298–333  ·  view source on GitHub ↗
(schemas)

Source from the content-addressed store, hash-verified

296}
297
298export async function getOpenApiSchemaFiles(schemas) {
299 const webhookSchemas = []
300 const restSchemas = []
301
302 // All of the schema releases that we store in allVersions
303 // Ex: 'api.github.com', 'ghec', 'ghes-3.6', 'ghes-3.5',
304 // 'ghes-3.4', 'ghes-3.3', 'ghes-3.2', 'github.ae'
305 const openApiVersions = Object.keys(allVersions).map(
306 (elem) => allVersions[elem].openApiVersionName
307 )
308 // The full list of dereferened OpenAPI schemas received from
309 // bundling the OpenAPI in github/github
310 const schemaBaseNames = schemas.map((schema) => path.basename(schema, '.deref.json'))
311 for (const schema of schemaBaseNames) {
312 // catches all of the schemas that are not
313 // calendar date versioned. Ex: ghec, ghes-3.7, and api.github.com
314 if (openApiVersions.includes(schema)) {
315 webhookSchemas.push(schema)
316 // Non-calendar date schemas could also match the calendar date versioned
317 // counterpart.
318 // Ex: api.github.com would match api.github.com and
319 // api.github.com.2022-09-09
320 const filteredMatches = schemaBaseNames.filter((elem) => elem.includes(schema))
321 // If there is only one match then there are no calendar date counterparts
322 // and this is the only schema for this plan and release.
323 if (filteredMatches.length === 1) {
324 restSchemas.push(schema)
325 }
326 // catches all of the calendar date versioned schemas in the
327 // format api.github.com.<year>-<month>-<day>
328 } else {
329 restSchemas.push(schema)
330 }
331 }
332 return { restSchemas, webhookSchemas }
333}

Callers 2

decorateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected