@mintlify/scraping 4.0.231 → 4.0.232
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__/getAsyncApiDefinition.test.ts +6 -9
- package/__test__/getOpenApiDefinition.test.ts +34 -9
- package/bin/asyncapi/generateAsyncApiPagesForDocsConfig.d.ts +1 -0
- package/bin/asyncapi/generateAsyncApiPagesForDocsConfig.js +1 -1
- package/bin/asyncapi/generateAsyncApiPagesForDocsConfig.js.map +1 -1
- package/bin/asyncapi/getAsyncApiDefinition.d.ts +1 -1
- package/bin/asyncapi/getAsyncApiDefinition.js +6 -6
- package/bin/asyncapi/getAsyncApiDefinition.js.map +1 -1
- package/bin/asyncapi/processAsyncApiChannel.js +1 -3
- package/bin/asyncapi/processAsyncApiChannel.js.map +1 -1
- package/bin/openapi/common.d.ts +2 -1
- package/bin/openapi/common.js +6 -6
- package/bin/openapi/common.js.map +1 -1
- package/bin/openapi/generateOpenApiPages.js +1 -1
- package/bin/openapi/generateOpenApiPages.js.map +1 -1
- package/bin/openapi/generateOpenApiPagesForDocsConfig.js +1 -1
- package/bin/openapi/generateOpenApiPagesForDocsConfig.js.map +1 -1
- package/bin/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/asyncapi/generateAsyncApiPagesForDocsConfig.ts +5 -2
- package/src/asyncapi/getAsyncApiDefinition.ts +15 -6
- package/src/asyncapi/processAsyncApiChannel.ts +1 -3
- package/src/openapi/common.ts +12 -5
- package/src/openapi/generateOpenApiPages.ts +1 -1
- package/src/openapi/generateOpenApiPagesForDocsConfig.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mintlify/scraping",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.232",
|
|
4
4
|
"description": "Scrape documentation frameworks to Mintlify docs",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18.0.0"
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"format:check": "prettier . --check"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@mintlify/common": "1.0.
|
|
41
|
+
"@mintlify/common": "1.0.376",
|
|
42
42
|
"@mintlify/openapi-parser": "^0.0.7",
|
|
43
43
|
"fs-extra": "^11.1.1",
|
|
44
44
|
"hast-util-to-mdast": "^10.1.0",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@mintlify/models": "0.0.189",
|
|
62
62
|
"@mintlify/prettier-config": "1.0.4",
|
|
63
63
|
"@mintlify/ts-config": "2.0.2",
|
|
64
|
-
"@mintlify/validation": "0.1.
|
|
64
|
+
"@mintlify/validation": "0.1.363",
|
|
65
65
|
"@trivago/prettier-plugin-sort-imports": "^4.2.1",
|
|
66
66
|
"@tsconfig/recommended": "1.x",
|
|
67
67
|
"@types/hast": "^3.0.4",
|
|
@@ -77,5 +77,5 @@
|
|
|
77
77
|
"typescript": "^5.5.3",
|
|
78
78
|
"vitest": "^2.0.4"
|
|
79
79
|
},
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "ffe9642893488f4fe43ea441b8c21d4fb3375adb"
|
|
81
81
|
}
|
|
@@ -13,6 +13,7 @@ type GenerateAsyncApiPagesOptions = {
|
|
|
13
13
|
outDir?: string;
|
|
14
14
|
outDirBasePath?: string;
|
|
15
15
|
overwrite?: boolean;
|
|
16
|
+
localSchema?: boolean;
|
|
16
17
|
};
|
|
17
18
|
|
|
18
19
|
type AsyncApiPageGenerationResult = {
|
|
@@ -30,8 +31,10 @@ export async function generateAsyncApiPagesForDocsConfig(
|
|
|
30
31
|
let document: AsyncAPIDocumentInterface | undefined = undefined;
|
|
31
32
|
let isUrl: boolean;
|
|
32
33
|
if (typeof spec === 'string' || spec instanceof URL) {
|
|
33
|
-
const { document: asyncApiDocument, isUrl: isUrlFromDefinition } =
|
|
34
|
-
|
|
34
|
+
const { document: asyncApiDocument, isUrl: isUrlFromDefinition } = await getAsyncApiDefinition(
|
|
35
|
+
spec,
|
|
36
|
+
opts?.localSchema
|
|
37
|
+
);
|
|
35
38
|
if (asyncApiDocument) {
|
|
36
39
|
document = asyncApiDocument;
|
|
37
40
|
}
|
|
@@ -1,17 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
AsyncAPIDocumentInterface,
|
|
3
|
+
validateAsyncApi,
|
|
4
|
+
isAllowedLocalSchemaUrl,
|
|
5
|
+
} from '@mintlify/common';
|
|
2
6
|
import * as fs from 'fs/promises';
|
|
3
7
|
import * as path from 'path';
|
|
4
8
|
|
|
5
9
|
import { fetchAsyncApi } from '../utils/network.js';
|
|
6
10
|
|
|
7
11
|
export const getAsyncApiDefinition = async (
|
|
8
|
-
pathOrDocumentOrUrl: string | URL
|
|
12
|
+
pathOrDocumentOrUrl: string | URL,
|
|
13
|
+
localSchema?: boolean
|
|
9
14
|
): Promise<{ document: AsyncAPIDocumentInterface | undefined; isUrl: boolean }> => {
|
|
10
15
|
let document: AsyncAPIDocumentInterface | undefined = undefined;
|
|
11
16
|
if (typeof pathOrDocumentOrUrl === 'string') {
|
|
12
|
-
if (pathOrDocumentOrUrl.startsWith('http
|
|
17
|
+
if (pathOrDocumentOrUrl.startsWith('http:') && !localSchema) {
|
|
13
18
|
// This is an invalid location either for a file or a URL
|
|
14
|
-
throw new Error(
|
|
19
|
+
throw new Error(
|
|
20
|
+
'Only HTTPS URLs are supported. HTTP URLs are only supported with the cli option --local-schema.'
|
|
21
|
+
);
|
|
15
22
|
} else {
|
|
16
23
|
try {
|
|
17
24
|
const url = new URL(pathOrDocumentOrUrl);
|
|
@@ -35,8 +42,10 @@ export const getAsyncApiDefinition = async (
|
|
|
35
42
|
}
|
|
36
43
|
const isUrl = pathOrDocumentOrUrl instanceof URL;
|
|
37
44
|
if (pathOrDocumentOrUrl instanceof URL) {
|
|
38
|
-
if (pathOrDocumentOrUrl.
|
|
39
|
-
throw new Error(
|
|
45
|
+
if (!isAllowedLocalSchemaUrl(pathOrDocumentOrUrl.toString(), localSchema)) {
|
|
46
|
+
throw new Error(
|
|
47
|
+
'Only HTTPS URLs are supported. HTTP URLs are only supported with the cli option --local-schema.'
|
|
48
|
+
);
|
|
40
49
|
}
|
|
41
50
|
document = await fetchAsyncApi(pathOrDocumentOrUrl);
|
|
42
51
|
}
|
|
@@ -49,9 +49,7 @@ export const processAsyncApiChannel = ({
|
|
|
49
49
|
findNavGroup,
|
|
50
50
|
}: ProcessAsyncApiChannelArgs) => {
|
|
51
51
|
const asyncApiFilePathFromRoot = opts?.asyncApiFilePath
|
|
52
|
-
? opts.asyncApiFilePath
|
|
53
|
-
? opts.asyncApiFilePath
|
|
54
|
-
: optionallyAddLeadingSlash(opts.asyncApiFilePath)
|
|
52
|
+
? optionallyAddLeadingSlash(opts.asyncApiFilePath)
|
|
55
53
|
: undefined;
|
|
56
54
|
|
|
57
55
|
const tags = channel.tags().all();
|
package/src/openapi/common.ts
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
OperationObject,
|
|
4
4
|
optionallyAddLeadingSlash,
|
|
5
5
|
slugToTitle,
|
|
6
|
+
isAllowedLocalSchemaUrl,
|
|
6
7
|
buildOpenApiMetaTag,
|
|
7
8
|
} from '@mintlify/common';
|
|
8
9
|
import type { DecoratedNavigationPage } from '@mintlify/models';
|
|
@@ -20,12 +21,15 @@ import {
|
|
|
20
21
|
import { fetchOpenApi } from '../utils/network.js';
|
|
21
22
|
|
|
22
23
|
export const getOpenApiDefinition = async (
|
|
23
|
-
pathOrDocumentOrUrl: string | OpenAPI.Document | URL
|
|
24
|
+
pathOrDocumentOrUrl: string | OpenAPI.Document | URL,
|
|
25
|
+
localSchema?: boolean
|
|
24
26
|
): Promise<{ document: OpenAPI.Document; isUrl: boolean }> => {
|
|
25
27
|
if (typeof pathOrDocumentOrUrl === 'string') {
|
|
26
|
-
if (pathOrDocumentOrUrl.startsWith('http
|
|
28
|
+
if (pathOrDocumentOrUrl.startsWith('http:') && !localSchema) {
|
|
27
29
|
// This is an invalid location either for a file or a URL
|
|
28
|
-
throw new Error(
|
|
30
|
+
throw new Error(
|
|
31
|
+
'Only HTTPS URLs are supported. HTTP URLs are only supported with the cli option --local-schema.'
|
|
32
|
+
);
|
|
29
33
|
} else {
|
|
30
34
|
try {
|
|
31
35
|
const url = new URL(pathOrDocumentOrUrl);
|
|
@@ -39,8 +43,10 @@ export const getOpenApiDefinition = async (
|
|
|
39
43
|
}
|
|
40
44
|
const isUrl = pathOrDocumentOrUrl instanceof URL;
|
|
41
45
|
if (pathOrDocumentOrUrl instanceof URL) {
|
|
42
|
-
if (pathOrDocumentOrUrl.
|
|
43
|
-
throw new Error(
|
|
46
|
+
if (!isAllowedLocalSchemaUrl(pathOrDocumentOrUrl.toString(), localSchema)) {
|
|
47
|
+
throw new Error(
|
|
48
|
+
'Only HTTPS URLs are supported. HTTP URLs are only supported with the cli option --local-schema.'
|
|
49
|
+
);
|
|
44
50
|
}
|
|
45
51
|
pathOrDocumentOrUrl = await fetchOpenApi(pathOrDocumentOrUrl);
|
|
46
52
|
}
|
|
@@ -75,6 +81,7 @@ export type GenerateOpenApiPagesOptions = {
|
|
|
75
81
|
outDir?: string;
|
|
76
82
|
outDirBasePath?: string;
|
|
77
83
|
overwrite?: boolean;
|
|
84
|
+
localSchema?: boolean;
|
|
78
85
|
};
|
|
79
86
|
|
|
80
87
|
export type OpenApiPageGenerationResult<N, DN> = {
|
|
@@ -21,7 +21,7 @@ export async function generateOpenApiPages(
|
|
|
21
21
|
pathOrDocumentOrUrl: string | OpenAPI.Document | URL,
|
|
22
22
|
opts?: GenerateOpenApiPagesOptions
|
|
23
23
|
): Promise<OpenApiPageGenerationResult<Navigation, DecoratedNavigation>> {
|
|
24
|
-
const { document, isUrl } = await getOpenApiDefinition(pathOrDocumentOrUrl);
|
|
24
|
+
const { document, isUrl } = await getOpenApiDefinition(pathOrDocumentOrUrl, opts?.localSchema);
|
|
25
25
|
const { schema } = await validate(document);
|
|
26
26
|
|
|
27
27
|
if (
|
|
@@ -16,7 +16,7 @@ export async function generateOpenApiPagesForDocsConfig(
|
|
|
16
16
|
pathOrDocumentOrUrl: string | OpenAPI.Document | URL,
|
|
17
17
|
opts?: GenerateOpenApiPagesOptions
|
|
18
18
|
): Promise<OpenApiPageGenerationResult<GroupsConfig, DecoratedGroupsConfig>> {
|
|
19
|
-
const { document, isUrl } = await getOpenApiDefinition(pathOrDocumentOrUrl);
|
|
19
|
+
const { document, isUrl } = await getOpenApiDefinition(pathOrDocumentOrUrl, opts?.localSchema);
|
|
20
20
|
const { schema } = await validate(document);
|
|
21
21
|
|
|
22
22
|
if (
|