MCPcopy Index your code
hub / github.com/github/docs / getRest

Function getRest

src/rest/lib/index.js:72–101  ·  view source on GitHub ↗
(version, apiVersion, category, subCategory)

Source from the content-addressed store, hash-verified

70// openApiVersion (below, every version has an openApiVersion mapping): There's a mapping between our Docs versions
71// and the OpenApi Version bc it's not the same
72export default async function getRest(version, apiVersion, category, subCategory) {
73 const openApiVersion = getOpenApiVersion(version)
74 const filename = apiVersion ? `${openApiVersion}.${apiVersion}.json` : `${openApiVersion}.json`
75 const apiDate = apiVersion || NOT_API_VERSIONED
76
77 if (!restOperations.has(openApiVersion)) {
78 restOperations.set(openApiVersion, new Map())
79 restOperations.get(openApiVersion).set(apiDate, new Map())
80 // The `readCompressedJsonFileFallback()` function
81 // will check for both a .br and .json extension.
82 restOperations
83 .get(openApiVersion)
84 .set(apiDate, readCompressedJsonFileFallback(path.join(schemasPath, filename)))
85 } else if (!restOperations.get(openApiVersion).has(apiDate)) {
86 restOperations.get(openApiVersion).set(apiDate, new Map())
87 // The `readCompressedJsonFileFallback()` function
88 // will check for both a .br and .json extension.
89 restOperations
90 .get(openApiVersion)
91 .set(apiDate, readCompressedJsonFileFallback(path.join(schemasPath, filename)))
92 }
93
94 if (subCategory) {
95 return restOperations.get(openApiVersion).get(apiDate)[category][subCategory]
96 } else if (category) {
97 return restOperations.get(openApiVersion).get(apiDate)[category]
98 } else {
99 return restOperations.get(openApiVersion).get(apiDate)
100 }
101}
102
103function getOpenApiVersion(version) {
104 if (!(version in allVersions)) {

Callers 5

getServerSidePropsFunction · 0.85
getServerSidePropsFunction · 0.85
getFlatListOfOperationsFunction · 0.85
openapi-schema.jsFile · 0.85
rest.jsFile · 0.85

Calls 2

getOpenApiVersionFunction · 0.70

Tested by

no test coverage detected