@mintlify/scraping 4.0.952 → 4.0.953
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -20,6 +20,19 @@ const mockOpenApiDoc: OpenAPI.Document = {
|
|
|
20
20
|
const httpsError =
|
|
21
21
|
'Only HTTPS URLs are supported. HTTP URLs are only supported with the cli option --local-schema.';
|
|
22
22
|
|
|
23
|
+
const MAX_BACKOFF_WAIT_MS = 1000 + 2000 + 4000;
|
|
24
|
+
|
|
25
|
+
async function withBackoffElapsed<T>(start: () => Promise<T>): Promise<T> {
|
|
26
|
+
vi.useFakeTimers();
|
|
27
|
+
try {
|
|
28
|
+
const pending = start();
|
|
29
|
+
await vi.advanceTimersByTimeAsync(MAX_BACKOFF_WAIT_MS);
|
|
30
|
+
return await pending;
|
|
31
|
+
} finally {
|
|
32
|
+
vi.useRealTimers();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
23
36
|
describe('getOpenApiDefinition', () => {
|
|
24
37
|
beforeEach(() => {
|
|
25
38
|
vi.resetAllMocks();
|
|
@@ -99,8 +112,10 @@ describe('getOpenApiDefinition', () => {
|
|
|
99
112
|
|
|
100
113
|
const urlString = 'https://petstore3.swagger.io/api/v3/openapi.doesnotexist';
|
|
101
114
|
|
|
102
|
-
await
|
|
103
|
-
|
|
115
|
+
await withBackoffElapsed(() =>
|
|
116
|
+
expect(getOpenApiDefinition(urlString)).rejects.toThrow(
|
|
117
|
+
'https://petstore3.swagger.io/api/v3/openapi.doesnotexist - failed to retrieve OpenAPI file from source: 404 Not Found'
|
|
118
|
+
)
|
|
104
119
|
);
|
|
105
120
|
|
|
106
121
|
expect(fetch).toHaveBeenCalledWith(new URL(urlString));
|
|
@@ -154,7 +169,9 @@ describe('getOpenApiDefinition', () => {
|
|
|
154
169
|
text: () => Promise.resolve('invalid: yaml: content'),
|
|
155
170
|
});
|
|
156
171
|
|
|
157
|
-
await
|
|
172
|
+
await withBackoffElapsed(() =>
|
|
173
|
+
expect(getOpenApiDefinition('https://example.com/openapi.yaml')).rejects.toThrow()
|
|
174
|
+
);
|
|
158
175
|
});
|
|
159
176
|
|
|
160
177
|
it('should throw error when URL response is invalid JSON', async () => {
|
|
@@ -162,7 +179,9 @@ describe('getOpenApiDefinition', () => {
|
|
|
162
179
|
text: () => Promise.resolve('{"invalid": "yaml", "invalid": "content"}'),
|
|
163
180
|
});
|
|
164
181
|
|
|
165
|
-
await
|
|
182
|
+
await withBackoffElapsed(() =>
|
|
183
|
+
expect(getOpenApiDefinition('https://example.com/openapi.json')).rejects.toThrow()
|
|
184
|
+
);
|
|
166
185
|
});
|
|
167
186
|
|
|
168
187
|
it('should throw error when local file contains invalid YAML', async () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mintlify/scraping",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.953",
|
|
4
4
|
"description": "Scrape documentation frameworks to Mintlify docs",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18.0.0"
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
"typescript": "5.5.3",
|
|
80
80
|
"vitest": "2.1.9"
|
|
81
81
|
},
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "870f80c1afe38366824889a5effc54f89e969d26"
|
|
83
83
|
}
|