@mintlify/scraping 4.0.1071 → 4.0.1073
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.
- package/__test__/openApiTagHierarchy.test.ts +286 -0
- package/bin/openapi/common.d.ts +5 -3
- package/bin/openapi/common.js +160 -149
- package/bin/openapi/common.js.map +1 -1
- package/bin/openapi/generateOpenApiPages.js +16 -5
- package/bin/openapi/generateOpenApiPages.js.map +1 -1
- package/bin/openapi/generateOpenApiPagesForDocsConfig.js +8 -3
- package/bin/openapi/generateOpenApiPagesForDocsConfig.js.map +1 -1
- package/bin/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/openapi/common.ts +198 -171
- package/src/openapi/generateOpenApiPages.ts +23 -5
- package/src/openapi/generateOpenApiPagesForDocsConfig.ts +14 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mintlify/scraping",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.1073",
|
|
4
4
|
"description": "Scrape documentation frameworks to Mintlify docs",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18.0.0"
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"format:check": "oxfmt --check"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@mintlify/common": "1.0.
|
|
46
|
+
"@mintlify/common": "1.0.1203",
|
|
47
47
|
"fast-xml-parser": "5.7.3",
|
|
48
48
|
"fs-extra": "11.1.1",
|
|
49
49
|
"graphql": "16.11.0",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@mintlify/models": "0.0.364",
|
|
66
66
|
"@mintlify/ts-config": "2.0.2",
|
|
67
|
-
"@mintlify/validation": "0.1.
|
|
67
|
+
"@mintlify/validation": "0.1.889",
|
|
68
68
|
"@tsconfig/recommended": "1.0.2",
|
|
69
69
|
"@types/hast": "3.0.4",
|
|
70
70
|
"@types/mdast": "4.0.4",
|
|
@@ -87,5 +87,5 @@
|
|
|
87
87
|
"optional": true
|
|
88
88
|
}
|
|
89
89
|
},
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "ae113e1c66224519c407cd9bbfb7c0c729a86628"
|
|
91
91
|
}
|
package/src/openapi/common.ts
CHANGED
|
@@ -10,12 +10,15 @@ import {
|
|
|
10
10
|
registerXMintContent,
|
|
11
11
|
prepareStringToBeValidFilename,
|
|
12
12
|
generateUniqueFilenameWithoutExtension,
|
|
13
|
-
|
|
13
|
+
createOpenApiBadgeResolver,
|
|
14
|
+
createOpenApiTagResolver,
|
|
15
|
+
findOpenApiNavGroup,
|
|
16
|
+
isOpenApi32,
|
|
14
17
|
mergePageGroups,
|
|
15
18
|
type LoadedOverlay,
|
|
16
19
|
} from '@mintlify/common';
|
|
17
20
|
import type { DecoratedNavigationPage, PageMetaTags } from '@mintlify/models';
|
|
18
|
-
import { XMint } from '@mintlify/validation';
|
|
21
|
+
import { getPathItemOperations, XMint } from '@mintlify/validation';
|
|
19
22
|
import { outputFile } from 'fs-extra';
|
|
20
23
|
import fse from 'fs-extra';
|
|
21
24
|
import fs from 'fs/promises';
|
|
@@ -104,7 +107,9 @@ export const createOpenApiFrontmatterContent = ({
|
|
|
104
107
|
Object.entries(metadata)
|
|
105
108
|
.filter(([k]) => !reserved.has(k))
|
|
106
109
|
.forEach(([key, value]) => {
|
|
107
|
-
|
|
110
|
+
const serialized =
|
|
111
|
+
typeof value === 'string' ? yaml.dump(value, { lineWidth: -1 }).trimEnd() : value;
|
|
112
|
+
frontmatter += `\n${key}: ${serialized}`;
|
|
108
113
|
});
|
|
109
114
|
}
|
|
110
115
|
|
|
@@ -135,6 +140,8 @@ export type GenerateOpenApiPagesOptions = {
|
|
|
135
140
|
mountPath?: string;
|
|
136
141
|
overwrite?: boolean;
|
|
137
142
|
localSchema?: boolean;
|
|
143
|
+
resolveTags?: ReturnType<typeof createOpenApiTagResolver>;
|
|
144
|
+
resolveBadge?: ReturnType<typeof createOpenApiBadgeResolver>;
|
|
138
145
|
writeFile?: (filename: string, content: string) => void | Promise<void>;
|
|
139
146
|
overlays?: readonly LoadedOverlay[];
|
|
140
147
|
};
|
|
@@ -170,121 +177,130 @@ export function processOpenApiPath<N, DN>(
|
|
|
170
177
|
pagesAcc: Record<string, DecoratedNavigationPage>,
|
|
171
178
|
options: GenerateOpenApiPagesOptions,
|
|
172
179
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
173
|
-
findNavGroup: (nav: any, groupName?: string) => any
|
|
180
|
+
findNavGroup: (nav: any, groupName?: string, tagKey?: string) => any
|
|
174
181
|
): string[] {
|
|
175
182
|
const openApiFilePathFromRoot = options.openApiFilePath
|
|
176
183
|
? optionallyAddLeadingSlash(options.openApiFilePath)
|
|
177
184
|
: undefined;
|
|
178
185
|
|
|
179
186
|
const generatedSlugs: string[] = [];
|
|
187
|
+
const resolveTags = options.resolveTags ?? createOpenApiTagResolver(schema);
|
|
188
|
+
const resolveBadge = options.resolveBadge ?? createOpenApiBadgeResolver(schema);
|
|
189
|
+
const nestedTags = isOpenApi32(schema);
|
|
180
190
|
|
|
181
|
-
|
|
182
|
-
if (
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
xMint.href = optionallyAddLeadingSlash(xMint.href);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
const tagName = operation?.tags?.[0];
|
|
198
|
-
const groupName = getTagDisplayName(tagName, schema);
|
|
199
|
-
let title =
|
|
200
|
-
prepareStringToBeValidFilename(operation?.summary) ??
|
|
201
|
-
`${method}-${prepareStringToBeValidFilename(path)}`;
|
|
202
|
-
|
|
203
|
-
let folder = prepareStringToBeValidFilename(tagName) ?? '';
|
|
204
|
-
let base = posix.join(options.outDir ?? '', folder, title);
|
|
205
|
-
|
|
206
|
-
if (xMint?.href) {
|
|
207
|
-
const slug = optionallyRemoveLeadingSlash(xMint.href);
|
|
208
|
-
title = posix.parse(slug).name;
|
|
209
|
-
folder = posix.parse(slug).dir;
|
|
210
|
-
base = posix.join(options.mountPath ?? '', folder, title);
|
|
211
|
-
}
|
|
191
|
+
getPathItemOperations(pathItemObject).forEach(([method, operation]) => {
|
|
192
|
+
if (isExcludedOperation(operation as MaybeOperationObjectWithExtensions)) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
const xMint = operation?.['x-mint'];
|
|
196
|
+
const xMintGroups = getXMintGroups({
|
|
197
|
+
pathObject: pathItemObject,
|
|
198
|
+
operationObject: operation,
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
if (xMint?.href) {
|
|
202
|
+
xMint.href = optionallyAddLeadingSlash(xMint.href);
|
|
203
|
+
}
|
|
212
204
|
|
|
213
|
-
|
|
214
|
-
|
|
205
|
+
const tagPath = resolveTags(operation?.tags);
|
|
206
|
+
const tagName = tagPath.at(-1)?.name;
|
|
207
|
+
let title =
|
|
208
|
+
prepareStringToBeValidFilename(operation?.summary) ??
|
|
209
|
+
`${method.toLowerCase()}-${prepareStringToBeValidFilename(path)}`;
|
|
215
210
|
|
|
216
|
-
|
|
211
|
+
let folder = prepareStringToBeValidFilename(tagName) ?? '';
|
|
212
|
+
let base = posix.join(options.outDir ?? '', folder, title);
|
|
217
213
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
[
|
|
225
|
-
{
|
|
226
|
-
filename: options.openApiFilePath
|
|
227
|
-
? parse(options.openApiFilePath).name
|
|
228
|
-
: 'filler-filename',
|
|
229
|
-
spec: schema,
|
|
230
|
-
originalFileLocation: openApiFilePathFromRoot,
|
|
231
|
-
},
|
|
232
|
-
],
|
|
233
|
-
openapiMetaTag
|
|
234
|
-
);
|
|
235
|
-
|
|
236
|
-
let xMintMetadata = xMint?.metadata;
|
|
237
|
-
if (xMintGroups.length > 0) {
|
|
238
|
-
xMintMetadata = {
|
|
239
|
-
...xMintMetadata,
|
|
240
|
-
groups: mergePageGroups(xMintMetadata?.groups, xMintGroups),
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
const slugTitle = slugToTitle(filenameWithoutExtension);
|
|
214
|
+
if (xMint?.href) {
|
|
215
|
+
const slug = optionallyRemoveLeadingSlash(xMint.href);
|
|
216
|
+
title = posix.parse(slug).name;
|
|
217
|
+
folder = posix.parse(slug).dir;
|
|
218
|
+
base = posix.join(options.mountPath ?? '', folder, title);
|
|
219
|
+
}
|
|
245
220
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
221
|
+
const hidden = isHiddenOperation(operation as MaybeOperationObjectWithExtensions);
|
|
222
|
+
const navGroup = hidden && nestedTags ? [] : findOpenApiNavGroup(nav, tagPath, findNavGroup);
|
|
223
|
+
const decoratedNavGroup =
|
|
224
|
+
hidden && nestedTags ? [] : findOpenApiNavGroup(decoratedNav, tagPath, findNavGroup);
|
|
225
|
+
|
|
226
|
+
const filenameWithoutExtension = generateUniqueFilenameWithoutExtension(
|
|
227
|
+
nestedTags ? pagesAcc : navGroup,
|
|
228
|
+
base
|
|
229
|
+
);
|
|
230
|
+
|
|
231
|
+
const openapiMetaTag = buildOpenApiMetaTag({
|
|
232
|
+
filePath: openApiFilePathFromRoot,
|
|
233
|
+
method,
|
|
234
|
+
path,
|
|
235
|
+
});
|
|
236
|
+
const { title: titleTag, description } = getOpenApiTitleAndDescription(
|
|
237
|
+
[
|
|
238
|
+
{
|
|
239
|
+
filename: options.openApiFilePath
|
|
240
|
+
? parse(options.openApiFilePath).name
|
|
241
|
+
: 'filler-filename',
|
|
242
|
+
spec: schema,
|
|
243
|
+
originalFileLocation: openApiFilePathFromRoot,
|
|
244
|
+
},
|
|
245
|
+
],
|
|
246
|
+
openapiMetaTag
|
|
247
|
+
);
|
|
248
|
+
|
|
249
|
+
let xMintMetadata = xMint?.metadata;
|
|
250
|
+
if (xMintGroups.length > 0) {
|
|
251
|
+
xMintMetadata = {
|
|
255
252
|
...xMintMetadata,
|
|
256
|
-
|
|
257
|
-
href: posix.resolve('/', filenameWithoutExtension),
|
|
253
|
+
groups: mergePageGroups(xMintMetadata?.groups, xMintGroups),
|
|
258
254
|
};
|
|
255
|
+
}
|
|
256
|
+
const badge = resolveBadge(operation?.tags);
|
|
257
|
+
if (badge !== undefined && xMintMetadata?.tag === undefined) {
|
|
258
|
+
xMintMetadata = { ...xMintMetadata, tag: badge };
|
|
259
|
+
}
|
|
259
260
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
261
|
+
const slugTitle = slugToTitle(filenameWithoutExtension);
|
|
262
|
+
|
|
263
|
+
const page: DecoratedNavigationPage = {
|
|
264
|
+
title: titleTag ?? slugTitle,
|
|
265
|
+
description,
|
|
266
|
+
deprecated: operation?.deprecated,
|
|
267
|
+
version: options.version,
|
|
268
|
+
// When a file-path spec has x-mint.href overriding the path, use the slug-derived
|
|
269
|
+
// title for the sidebar so the nav shows the user-chosen name rather than the
|
|
270
|
+
// OpenAPI summary. Only for openApiFilePath specs to avoid changing URL-based behavior.
|
|
271
|
+
...(xMint?.href && titleTag && options.openApiFilePath ? { sidebarTitle: slugTitle } : {}),
|
|
272
|
+
...xMintMetadata,
|
|
273
|
+
openapi: openapiMetaTag,
|
|
274
|
+
href: posix.resolve('/', filenameWithoutExtension),
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
if (!isHiddenOperation(operation as MaybeOperationObjectWithExtensions)) {
|
|
278
|
+
navGroup.push(filenameWithoutExtension);
|
|
279
|
+
decoratedNavGroup.push(page);
|
|
280
|
+
}
|
|
281
|
+
pagesAcc[filenameWithoutExtension] = page;
|
|
282
|
+
generatedSlugs.push(filenameWithoutExtension);
|
|
266
283
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
284
|
+
if (!options.writeFiles) {
|
|
285
|
+
registerXMintContent(filenameWithoutExtension, xMint?.content);
|
|
286
|
+
}
|
|
270
287
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
}
|
|
288
|
+
const targetPath = options.outDirBasePath
|
|
289
|
+
? join(options.outDirBasePath, `${filenameWithoutExtension}.mdx`)
|
|
290
|
+
: `${filenameWithoutExtension}.mdx`;
|
|
291
|
+
if (options.writeFiles && (!fse.pathExistsSync(targetPath) || options.overwrite)) {
|
|
292
|
+
const input = {
|
|
293
|
+
openApiMetaTag: openapiMetaTag,
|
|
294
|
+
version: options.version,
|
|
295
|
+
deprecated: operation?.deprecated,
|
|
296
|
+
metadata: xMintMetadata,
|
|
297
|
+
extraContent: xMint?.content,
|
|
298
|
+
};
|
|
299
|
+
writePromises.push(
|
|
300
|
+
options.writeFile
|
|
301
|
+
? Promise.resolve(options.writeFile(targetPath, createOpenApiFrontmatterContent(input)))
|
|
302
|
+
: createOpenApiFrontmatter({ filename: targetPath, ...input })
|
|
303
|
+
);
|
|
288
304
|
}
|
|
289
305
|
});
|
|
290
306
|
|
|
@@ -301,90 +317,101 @@ export function processOpenApiWebhook<N, DN>(
|
|
|
301
317
|
pagesAcc: Record<string, DecoratedNavigationPage>,
|
|
302
318
|
options: GenerateOpenApiPagesOptions,
|
|
303
319
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
304
|
-
findNavGroup: (nav: any, groupName?: string) => any
|
|
320
|
+
findNavGroup: (nav: any, groupName?: string, tagKey?: string) => any
|
|
305
321
|
): string[] {
|
|
306
322
|
const openApiFilePathFromRoot = options.openApiFilePath
|
|
307
323
|
? optionallyAddLeadingSlash(options.openApiFilePath)
|
|
308
324
|
: undefined;
|
|
309
325
|
|
|
310
326
|
const generatedSlugs: string[] = [];
|
|
327
|
+
const resolveTags = options.resolveTags ?? createOpenApiTagResolver(schema);
|
|
328
|
+
const resolveBadge = options.resolveBadge ?? createOpenApiBadgeResolver(schema);
|
|
329
|
+
const nestedTags = isOpenApi32(schema);
|
|
311
330
|
|
|
312
|
-
|
|
313
|
-
if (
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
}
|
|
318
|
-
const xMint = operation?.['x-mint'];
|
|
319
|
-
|
|
320
|
-
if (xMint?.href) {
|
|
321
|
-
xMint.href = optionallyAddLeadingSlash(xMint.href);
|
|
322
|
-
}
|
|
331
|
+
getPathItemOperations(webhookObject).forEach(([, operation]) => {
|
|
332
|
+
if (isExcludedOperation(operation as MaybeOperationObjectWithExtensions)) {
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
const xMint = operation?.['x-mint'];
|
|
323
336
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
prepareStringToBeValidFilename(operation?.summary) ??
|
|
328
|
-
`${prepareStringToBeValidFilename(webhook)}`;
|
|
329
|
-
let folder = prepareStringToBeValidFilename(tagName) ?? '';
|
|
330
|
-
let base = posix.join(options.outDir ?? '', folder, title);
|
|
331
|
-
|
|
332
|
-
if (xMint?.href) {
|
|
333
|
-
const slug = optionallyRemoveLeadingSlash(xMint.href);
|
|
334
|
-
title = posix.parse(slug).name;
|
|
335
|
-
folder = posix.parse(slug).dir;
|
|
336
|
-
base = posix.join(options.mountPath ?? '', folder, title);
|
|
337
|
-
}
|
|
337
|
+
if (xMint?.href) {
|
|
338
|
+
xMint.href = optionallyAddLeadingSlash(xMint.href);
|
|
339
|
+
}
|
|
338
340
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
+
const tagPath = resolveTags(operation?.tags);
|
|
342
|
+
const tagName = tagPath.at(-1)?.name;
|
|
343
|
+
let title =
|
|
344
|
+
prepareStringToBeValidFilename(operation?.summary) ??
|
|
345
|
+
`${prepareStringToBeValidFilename(webhook)}`;
|
|
346
|
+
let folder = prepareStringToBeValidFilename(tagName) ?? '';
|
|
347
|
+
let base = posix.join(options.outDir ?? '', folder, title);
|
|
348
|
+
|
|
349
|
+
if (xMint?.href) {
|
|
350
|
+
const slug = optionallyRemoveLeadingSlash(xMint.href);
|
|
351
|
+
title = posix.parse(slug).name;
|
|
352
|
+
folder = posix.parse(slug).dir;
|
|
353
|
+
base = posix.join(options.mountPath ?? '', folder, title);
|
|
354
|
+
}
|
|
341
355
|
|
|
342
|
-
|
|
356
|
+
const hidden = isHiddenOperation(operation as MaybeOperationObjectWithExtensions);
|
|
357
|
+
const navGroup = hidden && nestedTags ? [] : findOpenApiNavGroup(nav, tagPath, findNavGroup);
|
|
358
|
+
const decoratedNavGroup =
|
|
359
|
+
hidden && nestedTags ? [] : findOpenApiNavGroup(decoratedNav, tagPath, findNavGroup);
|
|
360
|
+
|
|
361
|
+
const filenameWithoutExtension = generateUniqueFilenameWithoutExtension(
|
|
362
|
+
nestedTags ? pagesAcc : navGroup,
|
|
363
|
+
base
|
|
364
|
+
);
|
|
365
|
+
|
|
366
|
+
const openapiMetaTag = buildOpenApiMetaTag({
|
|
367
|
+
filePath: openApiFilePathFromRoot,
|
|
368
|
+
method: 'webhook',
|
|
369
|
+
path: webhook,
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
const badge = resolveBadge(operation?.tags);
|
|
373
|
+
const xMintMetadata =
|
|
374
|
+
badge !== undefined && xMint?.metadata?.tag === undefined
|
|
375
|
+
? { ...xMint?.metadata, tag: badge }
|
|
376
|
+
: xMint?.metadata;
|
|
377
|
+
|
|
378
|
+
const page: DecoratedNavigationPage = {
|
|
379
|
+
title: slugToTitle(filenameWithoutExtension),
|
|
380
|
+
description: operation?.description,
|
|
381
|
+
version: options.version,
|
|
382
|
+
deprecated: operation?.deprecated,
|
|
383
|
+
...xMintMetadata,
|
|
384
|
+
openapi: openapiMetaTag,
|
|
385
|
+
href: posix.resolve('/', filenameWithoutExtension),
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
if (!isHiddenOperation(operation as MaybeOperationObjectWithExtensions)) {
|
|
389
|
+
navGroup.push(filenameWithoutExtension);
|
|
390
|
+
decoratedNavGroup.push(page);
|
|
391
|
+
}
|
|
392
|
+
pagesAcc[filenameWithoutExtension] = page;
|
|
393
|
+
generatedSlugs.push(filenameWithoutExtension);
|
|
343
394
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
path: webhook,
|
|
348
|
-
});
|
|
395
|
+
if (!options.writeFiles) {
|
|
396
|
+
registerXMintContent(filenameWithoutExtension, xMint?.content);
|
|
397
|
+
}
|
|
349
398
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
399
|
+
const targetPath = options.outDirBasePath
|
|
400
|
+
? join(options.outDirBasePath, `${filenameWithoutExtension}.mdx`)
|
|
401
|
+
: `${filenameWithoutExtension}.mdx`;
|
|
402
|
+
if (options.writeFiles && (!fse.pathExistsSync(targetPath) || options.overwrite)) {
|
|
403
|
+
const input = {
|
|
404
|
+
openApiMetaTag: openapiMetaTag,
|
|
353
405
|
version: options.version,
|
|
354
406
|
deprecated: operation?.deprecated,
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
href: posix.resolve('/', filenameWithoutExtension),
|
|
407
|
+
metadata: xMintMetadata,
|
|
408
|
+
extraContent: xMint?.content,
|
|
358
409
|
};
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
pagesAcc[filenameWithoutExtension] = page;
|
|
365
|
-
generatedSlugs.push(filenameWithoutExtension);
|
|
366
|
-
|
|
367
|
-
if (!options.writeFiles) {
|
|
368
|
-
registerXMintContent(filenameWithoutExtension, xMint?.content);
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
const targetPath = options.outDirBasePath
|
|
372
|
-
? join(options.outDirBasePath, `${filenameWithoutExtension}.mdx`)
|
|
373
|
-
: `${filenameWithoutExtension}.mdx`;
|
|
374
|
-
if (options.writeFiles && (!fse.pathExistsSync(targetPath) || options.overwrite)) {
|
|
375
|
-
const input = {
|
|
376
|
-
openApiMetaTag: openapiMetaTag,
|
|
377
|
-
version: options.version,
|
|
378
|
-
deprecated: operation?.deprecated,
|
|
379
|
-
metadata: xMint?.metadata,
|
|
380
|
-
extraContent: xMint?.content,
|
|
381
|
-
};
|
|
382
|
-
writePromises.push(
|
|
383
|
-
options.writeFile
|
|
384
|
-
? Promise.resolve(options.writeFile(targetPath, createOpenApiFrontmatterContent(input)))
|
|
385
|
-
: createOpenApiFrontmatter({ filename: targetPath, ...input })
|
|
386
|
-
);
|
|
387
|
-
}
|
|
410
|
+
writePromises.push(
|
|
411
|
+
options.writeFile
|
|
412
|
+
? Promise.resolve(options.writeFile(targetPath, createOpenApiFrontmatterContent(input)))
|
|
413
|
+
: createOpenApiFrontmatter({ filename: targetPath, ...input })
|
|
414
|
+
);
|
|
388
415
|
}
|
|
389
416
|
});
|
|
390
417
|
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
createOpenApiBadgeResolver,
|
|
3
|
+
createOpenApiTagResolver,
|
|
4
|
+
validate,
|
|
5
|
+
DEFAULT_API_GROUP_NAME,
|
|
6
|
+
} from '@mintlify/common';
|
|
2
7
|
import type {
|
|
3
8
|
DecoratedNavigation,
|
|
4
9
|
DecoratedNavigationGroup,
|
|
@@ -40,6 +45,12 @@ export async function generateOpenApiPages(
|
|
|
40
45
|
throw new Error('No paths or webhooks defined.');
|
|
41
46
|
}
|
|
42
47
|
|
|
48
|
+
const generationOptions = {
|
|
49
|
+
...opts,
|
|
50
|
+
resolveTags: createOpenApiTagResolver(schema as OpenAPI.Document),
|
|
51
|
+
resolveBadge: createOpenApiBadgeResolver(schema as OpenAPI.Document),
|
|
52
|
+
};
|
|
53
|
+
|
|
43
54
|
const nav: Navigation = [];
|
|
44
55
|
const decoratedNav: DecoratedNavigation = [];
|
|
45
56
|
const writePromises: Promise<void>[] = [];
|
|
@@ -58,7 +69,7 @@ export async function generateOpenApiPages(
|
|
|
58
69
|
decoratedNav,
|
|
59
70
|
writePromises,
|
|
60
71
|
pagesAcc,
|
|
61
|
-
|
|
72
|
+
generationOptions,
|
|
62
73
|
findNavGroup
|
|
63
74
|
);
|
|
64
75
|
});
|
|
@@ -77,7 +88,7 @@ export async function generateOpenApiPages(
|
|
|
77
88
|
decoratedNav,
|
|
78
89
|
writePromises,
|
|
79
90
|
pagesAcc,
|
|
80
|
-
|
|
91
|
+
generationOptions,
|
|
81
92
|
findNavGroup
|
|
82
93
|
);
|
|
83
94
|
});
|
|
@@ -94,19 +105,26 @@ export async function generateOpenApiPages(
|
|
|
94
105
|
};
|
|
95
106
|
}
|
|
96
107
|
|
|
108
|
+
const tagKeys = new WeakMap<object, string>();
|
|
109
|
+
|
|
97
110
|
const findNavGroup = <T extends NavigationGroup | DecoratedNavigationGroup>(
|
|
98
111
|
nav: T['pages'][number][],
|
|
99
|
-
groupName: string = DEFAULT_API_GROUP_NAME
|
|
112
|
+
groupName: string = DEFAULT_API_GROUP_NAME,
|
|
113
|
+
tagKey?: string
|
|
100
114
|
): T['pages'][number][] => {
|
|
101
115
|
const group = nav.find(
|
|
102
116
|
(fileOrGroup) =>
|
|
103
|
-
typeof fileOrGroup === 'object' &&
|
|
117
|
+
typeof fileOrGroup === 'object' &&
|
|
118
|
+
'group' in fileOrGroup &&
|
|
119
|
+
fileOrGroup.group === groupName &&
|
|
120
|
+
(tagKey === undefined || tagKeys.get(fileOrGroup) === tagKey)
|
|
104
121
|
) as T | undefined;
|
|
105
122
|
if (group === undefined) {
|
|
106
123
|
const newGroup = {
|
|
107
124
|
group: groupName,
|
|
108
125
|
pages: [],
|
|
109
126
|
};
|
|
127
|
+
if (tagKey !== undefined) tagKeys.set(newGroup, tagKey);
|
|
110
128
|
nav.push(newGroup);
|
|
111
129
|
return newGroup.pages;
|
|
112
130
|
} else {
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
createOpenApiBadgeResolver,
|
|
3
|
+
createOpenApiTagResolver,
|
|
4
|
+
validate,
|
|
5
|
+
findNavGroup,
|
|
6
|
+
} from '@mintlify/common';
|
|
2
7
|
import { DecoratedNavigationPage } from '@mintlify/models';
|
|
3
8
|
import { DecoratedGroupsConfig, GroupsConfig } from '@mintlify/validation';
|
|
4
9
|
import { OpenAPI } from 'openapi-types';
|
|
@@ -35,6 +40,12 @@ export async function generateOpenApiPagesForDocsConfig(
|
|
|
35
40
|
throw new Error('No paths or webhooks defined.');
|
|
36
41
|
}
|
|
37
42
|
|
|
43
|
+
const generationOptions = {
|
|
44
|
+
...opts,
|
|
45
|
+
resolveTags: createOpenApiTagResolver(schema as OpenAPI.Document),
|
|
46
|
+
resolveBadge: createOpenApiBadgeResolver(schema as OpenAPI.Document),
|
|
47
|
+
};
|
|
48
|
+
|
|
38
49
|
const nav: GroupsConfig = [];
|
|
39
50
|
const decoratedNav: DecoratedGroupsConfig = [];
|
|
40
51
|
const writePromises: Promise<void>[] = [];
|
|
@@ -53,7 +64,7 @@ export async function generateOpenApiPagesForDocsConfig(
|
|
|
53
64
|
decoratedNav,
|
|
54
65
|
writePromises,
|
|
55
66
|
pagesAcc,
|
|
56
|
-
|
|
67
|
+
generationOptions,
|
|
57
68
|
findNavGroup
|
|
58
69
|
);
|
|
59
70
|
});
|
|
@@ -72,7 +83,7 @@ export async function generateOpenApiPagesForDocsConfig(
|
|
|
72
83
|
decoratedNav,
|
|
73
84
|
writePromises,
|
|
74
85
|
pagesAcc,
|
|
75
|
-
|
|
86
|
+
generationOptions,
|
|
76
87
|
findNavGroup
|
|
77
88
|
);
|
|
78
89
|
});
|