Skip to content

Commit b382908

Browse files
mongodbenBen Perlmutter
andauthored
(EAI-1071): Fix broken Atlas OpenAPI ingest (#765)
* update to fix broken test * Update packages/ingest-mongodb-public/src/sources/snooty/snootyAstToOpenApiSpec.ts --------- Co-authored-by: Ben Perlmutter <mongodben@mongodb.com>
1 parent c624ed4 commit b382908

File tree

2 files changed

+93
-14
lines changed

2 files changed

+93
-14
lines changed

packages/ingest-mongodb-public/src/sources/snooty/snootyAstToOpenApiSpec.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,15 @@ export const snootyAstToOpenApiSpec = async (
1616
// Have to hard code how the Atlas OpenAPI spec is loaded for now.
1717
// There is no programmatic way to get the spec resource from the Snooty AST.
1818
} else if (node?.options?.source_type === "atlas") {
19-
const version = node?.options?.["api-version"] || "2.0";
19+
const versions: Record<string, string> = {
20+
"2.0": "v2",
21+
};
22+
const snootyVersion = node?.options?.["api-version"] as
23+
| string
24+
| undefined;
25+
const version = versions[snootyVersion ?? "2.0"];
2026
const data = await fetch(
21-
"https://cloud.mongodb.com/api/openapi/spec/" + version
27+
`https://raw.githubusercontent.com/mongodb/openapi/refs/heads/main/openapi/${version}.json`
2228
);
2329
const json = await data.json();
2430
const text = yaml.stringify(json);
Lines changed: 85 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,35 @@
11
{
22
"type": "page",
33
"data": {
4-
"_id": "648b646e259a8493e5ac023b",
4+
"_id": "68261afb764f757313ea00a0",
55
"page_id": "cloud-docs/docsworker-xlarge/master/reference/api-resources-spec/v2",
66
"ast": {
77
"type": "root",
8-
"position": { "start": { "line": 0 } },
8+
"position": {
9+
"start": {
10+
"line": 0
11+
}
12+
},
913
"children": [
1014
{
1115
"type": "target",
12-
"position": { "start": { "line": 0 } },
16+
"position": {
17+
"start": {
18+
"line": 0
19+
}
20+
},
1321
"children": [
1422
{
1523
"type": "target_identifier",
16-
"position": { "start": { "line": 0 } },
24+
"position": {
25+
"start": {
26+
"line": 0
27+
}
28+
},
1729
"children": [],
18-
"ids": ["api-resources-spec"]
30+
"ids": [
31+
"api-resources-spec"
32+
]
1933
}
2034
],
2135
"domain": "std",
@@ -24,28 +38,59 @@
2438
},
2539
{
2640
"type": "directive",
27-
"position": { "start": { "line": 5 } },
41+
"position": {
42+
"start": {
43+
"line": 5
44+
}
45+
},
2846
"children": [],
2947
"domain": "",
3048
"name": "default-domain",
3149
"argument": [
3250
{
3351
"type": "text",
34-
"position": { "start": { "line": 5 } },
52+
"position": {
53+
"start": {
54+
"line": 5
55+
}
56+
},
3557
"value": "mongodb"
3658
}
3759
]
3860
},
3961
{
4062
"type": "directive",
41-
"position": { "start": { "line": 7 } },
63+
"position": {
64+
"start": {
65+
"line": 11
66+
}
67+
},
68+
"children": [],
69+
"domain": "",
70+
"name": "meta",
71+
"argument": [],
72+
"options": {
73+
"keywords": "code example"
74+
}
75+
},
76+
{
77+
"type": "directive",
78+
"position": {
79+
"start": {
80+
"line": 14
81+
}
82+
},
4283
"children": [],
4384
"domain": "mongodb",
4485
"name": "openapi",
4586
"argument": [
4687
{
4788
"type": "text",
48-
"position": { "start": { "line": 7 } },
89+
"position": {
90+
"start": {
91+
"line": 14
92+
}
93+
},
4994
"value": "cloud"
5095
}
5196
],
@@ -62,10 +107,38 @@
62107
"title": "MongoDB Atlas Administration API Specification"
63108
}
64109
},
65-
"created_at": "2023-06-15T19:20:13.276Z",
110+
"build_id": "68261af48cc93f2aff512d74",
111+
"created_at": "2025-05-15T16:48:56.475Z",
66112
"deleted": false,
113+
"facets": [
114+
{
115+
"category": "programming_language",
116+
"value": "json",
117+
"sub_facets": null,
118+
"display_name": "JSON"
119+
},
120+
{
121+
"category": "genre",
122+
"value": "reference",
123+
"sub_facets": null,
124+
"display_name": "Reference"
125+
},
126+
{
127+
"category": "target_product",
128+
"value": "atlas",
129+
"sub_facets": [
130+
{
131+
"category": "sub_product",
132+
"value": "online-archive",
133+
"sub_facets": null,
134+
"display_name": "Online Archive"
135+
}
136+
],
137+
"display_name": "Atlas"
138+
}
139+
],
67140
"filename": "reference/api-resources-spec/v2.txt",
68141
"static_assets": [],
69-
"updated_at": "2023-07-12T17:59:55.205Z"
142+
"updated_at": "2025-05-15T16:48:56.475Z"
70143
}
71-
}
144+
}

0 commit comments

Comments
 (0)