(version, apiVersion, category, subCategory)
| 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 |
| 72 | export 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 | |
| 103 | function getOpenApiVersion(version) { |
| 104 | if (!(version in allVersions)) { |
no test coverage detected