Skip to content

Commit 4912fa5

Browse files
committed
Update IDs and ensure v2 latest branch is correct
1 parent e8089e6 commit 4912fa5

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

.github/scripts/generateSpecMapping.js

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,54 @@ import { fileURLToPath } from 'node:url';
44

55
const __filename = fileURLToPath(import.meta.url);
66
const __dirname = path.dirname(__filename);
7-
const ATLAS_ADMIN_API_V2_DOC = 'atlas-admin-api-v2';
87

98
const SPEC_MAPPING = [
109
{
11-
doc: 'atlas-admin-api-v1',
10+
doc: 'f929d2d7-27d7-4591-b22f-6c2e543a7874',
1211
file: 'openapi/v1-deprecated/v1.json',
1312
branch: 'main',
1413
},
15-
// Need to programmatically handle resource versions separately
16-
{
17-
doc: ATLAS_ADMIN_API_V2_DOC,
18-
file: 'openapi/v2.json',
19-
branch: 'latest',
20-
},
2114
];
2215

2316
/**
2417
* Handles the resource versions for Atlas Admin API v2
2518
*/
26-
function handleResourceVersions() {
19+
function handleAdminAPIv2() {
20+
const docId = '2accf4b8-a543-426c-94c3-794ae26b68be';
2721
const directory = 'openapi/v2';
2822
const filePath = path.join(__dirname, `../../${directory}/versions.json`);
2923
const versions = JSON.parse(fs.readFileSync(filePath, 'utf8'));
3024

31-
for (const version of versions) {
25+
if (!versions || !Array.isArray(versions)) {
26+
return;
27+
}
28+
29+
for (const [index, version] of versions.entries()) {
3230
const openapiFilename = `openapi-${version}.json`;
3331
const openapiFilePath = path.join(path.dirname(filePath), openapiFilename);
3432

3533
if (!fs.existsSync(openapiFilePath)) {
3634
continue;
3735
}
3836

37+
const file = `${directory}/${openapiFilename}`;
3938
SPEC_MAPPING.push({
40-
doc: ATLAS_ADMIN_API_V2_DOC,
41-
file: `${directory}/${openapiFilename}`,
39+
doc: docId,
40+
file,
4241
branch: version,
4342
});
43+
44+
// We want the latest version to have its own version AND be the latest/default branch
45+
if (index === versions.length - 1) {
46+
SPEC_MAPPING.push({
47+
doc: docId,
48+
file,
49+
branch: 'latest',
50+
});
51+
}
4452
}
4553
}
4654

47-
handleResourceVersions();
55+
handleAdminAPIv2();
56+
// Output to GH action
4857
console.log(JSON.stringify(SPEC_MAPPING));

.github/workflows/generate-bump-pages.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Check & deploy API documentation
22

33
on:
4+
workflow_dispatch: # Allow manual trigger in case of quick fix
45
push:
56
branches:
67
- main

0 commit comments

Comments
 (0)