@mintlify/validation 0.1.38 → 0.1.40
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/LICENSE +21 -21
- package/README.md +55 -55
- package/dist/index.d.ts +11 -6
- package/dist/index.js +1 -1
- package/dist/mint-config/common.d.ts +6 -6
- package/dist/mint-config/flattenUnionErrorMessages.d.ts +7 -7
- package/dist/mint-config/hexadecimalPattern.d.ts +1 -1
- package/dist/mint-config/schemas/analytics.d.ts +171 -171
- package/dist/mint-config/schemas/anchorColors.d.ts +14 -14
- package/dist/mint-config/schemas/anchors.d.ts +46 -46
- package/dist/mint-config/schemas/colors.d.ts +61 -61
- package/dist/mint-config/schemas/config.d.ts +816 -798
- package/dist/mint-config/schemas/favicon.d.ts +2 -2
- package/dist/mint-config/schemas/name.d.ts +2 -2
- package/dist/mint-config/schemas/navigation.d.ts +3 -3
- package/dist/mint-config/schemas/tabs.d.ts +11 -11
- package/dist/mint-config/schemas/versions.d.ts +11 -11
- package/dist/mint-config/types/analytics.d.ts +3 -3
- package/dist/mint-config/types/anchors.d.ts +4 -3
- package/dist/mint-config/types/colors.d.ts +3 -3
- package/dist/mint-config/types/config.d.ts +3 -3
- package/dist/mint-config/types/navigation.d.ts +6 -6
- package/dist/mint-config/types/versions.d.ts +3 -3
- package/dist/mint-config/validateAnchorsWarnings.d.ts +4 -4
- package/dist/mint-config/validateVersionsInNavigation.d.ts +5 -5
- package/dist/openapi/convertOpenApi.d.ts +18 -17
- package/dist/openapi/convertParameters.d.ts +9 -8
- package/dist/openapi/convertSchema.d.ts +11 -11
- package/dist/openapi/convertSecurity.d.ts +14 -13
- package/dist/openapi/convertServers.d.ts +8 -8
- package/dist/openapi/types/endpoint.d.ts +128 -128
- package/dist/schemas/analytics.d.ts +171 -0
- package/dist/schemas/anchorColors.d.ts +14 -0
- package/dist/schemas/anchors.d.ts +46 -0
- package/dist/schemas/colors.d.ts +61 -0
- package/dist/schemas/config.d.ts +798 -0
- package/dist/schemas/favicon.d.ts +2 -0
- package/dist/schemas/name.d.ts +2 -0
- package/dist/schemas/navigation.d.ts +3 -0
- package/dist/schemas/tabs.d.ts +11 -0
- package/dist/schemas/versions.d.ts +11 -0
- package/dist/types/analytics.d.ts +3 -0
- package/dist/types/anchors.d.ts +3 -0
- package/dist/types/colors.d.ts +3 -0
- package/dist/types/config.d.ts +3 -0
- package/dist/types/endpoint.d.ts +125 -0
- package/dist/types/navigation.d.ts +6 -0
- package/dist/types/versions.d.ts +3 -0
- package/dist/utils/common.d.ts +6 -0
- package/dist/utils/convertOpenApi.d.ts +43 -0
- package/dist/utils/flattenUnionErrorMessages.d.ts +7 -0
- package/dist/utils/hexadecimalPattern.d.ts +1 -0
- package/dist/utils/validateAnchorsWarnings.d.ts +4 -0
- package/dist/utils/validateVersionsInNavigation.d.ts +5 -0
- package/package.json +74 -72
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const versionsSchema: z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
3
|
+
name: z.ZodString;
|
|
4
|
+
url: z.ZodString;
|
|
5
|
+
}, "strict", z.ZodTypeAny, {
|
|
6
|
+
name: string;
|
|
7
|
+
url: string;
|
|
8
|
+
}, {
|
|
9
|
+
name: string;
|
|
10
|
+
url: string;
|
|
11
|
+
}>]>, "many">;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
export type Endpoint = {
|
|
2
|
+
description?: string;
|
|
3
|
+
path: string;
|
|
4
|
+
method: HttpMethod;
|
|
5
|
+
servers?: Server[];
|
|
6
|
+
request: RequestSchema;
|
|
7
|
+
response: ResponseSchema;
|
|
8
|
+
deprecated: boolean;
|
|
9
|
+
};
|
|
10
|
+
export type Server = {
|
|
11
|
+
url: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
variables?: {
|
|
14
|
+
[variableName: string]: ServerVariableSchema;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export type ServerVariableSchema = ServerVariableStringSchema | ServerVariableStringEnumSchema;
|
|
18
|
+
export type ServerVariableStringSchema = {
|
|
19
|
+
type: 'string';
|
|
20
|
+
default: string;
|
|
21
|
+
description?: string;
|
|
22
|
+
};
|
|
23
|
+
export type ServerVariableStringEnumSchema = {
|
|
24
|
+
type: 'stringEnum';
|
|
25
|
+
enum: string[];
|
|
26
|
+
default: string;
|
|
27
|
+
description?: string;
|
|
28
|
+
};
|
|
29
|
+
export type HttpMethod = "get" | "put" | "post" | "delete" | "options" | "head" | "patch" | "trace";
|
|
30
|
+
export type RequestSchema = {
|
|
31
|
+
security: SecurityOption[];
|
|
32
|
+
parameters: ParameterSections;
|
|
33
|
+
body: BodySchema;
|
|
34
|
+
};
|
|
35
|
+
export type SecurityOption = NonPathParameterSections & {
|
|
36
|
+
title: string;
|
|
37
|
+
};
|
|
38
|
+
export type BodySchema = {
|
|
39
|
+
[contentType: string]: DataSchemaArray;
|
|
40
|
+
};
|
|
41
|
+
export type ParameterSchema = {
|
|
42
|
+
required: boolean;
|
|
43
|
+
description?: string;
|
|
44
|
+
deprecated: boolean;
|
|
45
|
+
schema: DataSchemaArray | 'basic' | 'bearer';
|
|
46
|
+
};
|
|
47
|
+
export type PathParameterSchema = ParameterSchema & {
|
|
48
|
+
required: true;
|
|
49
|
+
};
|
|
50
|
+
export type ParameterGroup = {
|
|
51
|
+
[name: string]: ParameterSchema;
|
|
52
|
+
};
|
|
53
|
+
export type PathParameterGroup = {
|
|
54
|
+
[name: string]: PathParameterSchema;
|
|
55
|
+
};
|
|
56
|
+
type NonPathParameterLocations = 'query' | 'header' | 'cookie';
|
|
57
|
+
type PathParameterLocations = 'path';
|
|
58
|
+
export type ParameterLocations = NonPathParameterLocations | PathParameterLocations;
|
|
59
|
+
type NonPathParameterSections = Record<NonPathParameterLocations, ParameterGroup>;
|
|
60
|
+
type PathParameterSections = Record<PathParameterLocations, PathParameterGroup>;
|
|
61
|
+
export type ParameterSections = NonPathParameterSections & PathParameterSections;
|
|
62
|
+
export type ResponseSchema = {
|
|
63
|
+
[code: string]: BodySchema;
|
|
64
|
+
};
|
|
65
|
+
export type DataSchemaArray = [DataSchema, ...DataSchema[]];
|
|
66
|
+
export declare const typeList: readonly ["boolean", "string", "number", "integer", "object", "array", "stringEnum", "numberEnum", "integerEnum", "null"];
|
|
67
|
+
export type SchemaType = typeof typeList[number];
|
|
68
|
+
export type DataSchema = BooleanSchema | StringSchema | NumberSchema | ObjectSchema | ArraySchema | StringEnumSchema | NumberEnumSchema | NullSchema;
|
|
69
|
+
export type BaseSchema<T> = {
|
|
70
|
+
type: SchemaType;
|
|
71
|
+
title?: string;
|
|
72
|
+
description?: string;
|
|
73
|
+
default?: T;
|
|
74
|
+
example?: T;
|
|
75
|
+
required?: boolean;
|
|
76
|
+
readOnly?: boolean;
|
|
77
|
+
writeOnly?: boolean;
|
|
78
|
+
deprecated?: boolean;
|
|
79
|
+
};
|
|
80
|
+
export type BooleanSchema = {
|
|
81
|
+
type: 'boolean';
|
|
82
|
+
} & BaseSchema<boolean>;
|
|
83
|
+
export type StringSchema = {
|
|
84
|
+
type: 'string';
|
|
85
|
+
format?: string;
|
|
86
|
+
pattern?: string;
|
|
87
|
+
maxLength?: number;
|
|
88
|
+
minLength?: number;
|
|
89
|
+
} & BaseSchema<string>;
|
|
90
|
+
export type NumberSchema = {
|
|
91
|
+
type: 'number' | 'integer';
|
|
92
|
+
multipleOf?: number;
|
|
93
|
+
maximum?: number;
|
|
94
|
+
exclusiveMaximum?: boolean;
|
|
95
|
+
minimum?: number;
|
|
96
|
+
exclusiveMinimum?: boolean;
|
|
97
|
+
} & BaseSchema<number>;
|
|
98
|
+
export type ObjectSchema = {
|
|
99
|
+
type: 'object';
|
|
100
|
+
additionalProperties?: boolean | DataSchemaArray;
|
|
101
|
+
maxProperties?: number;
|
|
102
|
+
minProperties?: number;
|
|
103
|
+
properties: {
|
|
104
|
+
[key: string]: DataSchemaArray;
|
|
105
|
+
};
|
|
106
|
+
} & BaseSchema<object>;
|
|
107
|
+
export type ArraySchema = {
|
|
108
|
+
type: 'array';
|
|
109
|
+
items: DataSchemaArray;
|
|
110
|
+
maxItems?: number;
|
|
111
|
+
minItems?: number;
|
|
112
|
+
uniqueItems?: boolean;
|
|
113
|
+
} & BaseSchema<unknown[]>;
|
|
114
|
+
export type StringEnumSchema = {
|
|
115
|
+
type: 'stringEnum';
|
|
116
|
+
enum: string[];
|
|
117
|
+
} & BaseSchema<string>;
|
|
118
|
+
export type NumberEnumSchema = {
|
|
119
|
+
type: 'numberEnum' | 'integerEnum';
|
|
120
|
+
enum: number[];
|
|
121
|
+
} & BaseSchema<number>;
|
|
122
|
+
export type NullSchema = {
|
|
123
|
+
type: 'null';
|
|
124
|
+
} & BaseSchema<null>;
|
|
125
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { OpenAPIV3_1 } from 'openapi-types';
|
|
2
|
+
import type { BodySchema, DataSchemaArray, Endpoint, HttpMethod, ParameterSections, ResponseSchema, SecurityOption, Server } from '../types/endpoint';
|
|
3
|
+
export declare class InvalidSchemaError extends Error {
|
|
4
|
+
constructor(message?: string);
|
|
5
|
+
}
|
|
6
|
+
export declare class ImpossibleSchemaError extends Error {
|
|
7
|
+
constructor(message?: string);
|
|
8
|
+
}
|
|
9
|
+
export declare class ConversionError extends Error {
|
|
10
|
+
constructor(message?: string);
|
|
11
|
+
}
|
|
12
|
+
type ConvertServersParams = OpenAPIV3_1.ServerObject[] | undefined;
|
|
13
|
+
type ConvertServersType = Server[] | undefined;
|
|
14
|
+
export declare const convertServers: (servers: ConvertServersParams) => ConvertServersType;
|
|
15
|
+
type ConvertParametersParams = {
|
|
16
|
+
pathParameters?: OpenAPIV3_1.ParameterObject[];
|
|
17
|
+
operationParameters?: OpenAPIV3_1.ParameterObject[];
|
|
18
|
+
};
|
|
19
|
+
export declare const convertParameters: ({ pathParameters, operationParameters, }: ConvertParametersParams) => ParameterSections;
|
|
20
|
+
export declare const convertSchema: (schema?: OpenAPIV3_1.SchemaObject, required?: boolean) => DataSchemaArray;
|
|
21
|
+
export declare const combineTopLevelSchemas: (schema1: OpenAPIV3_1.SchemaObject, schema2: OpenAPIV3_1.SchemaObject) => OpenAPIV3_1.SchemaObject;
|
|
22
|
+
export declare const convertProperties: (properties?: {
|
|
23
|
+
[key: string]: OpenAPIV3_1.SchemaObject;
|
|
24
|
+
} | undefined, required?: string[]) => {
|
|
25
|
+
[key: string]: DataSchemaArray;
|
|
26
|
+
};
|
|
27
|
+
type ConvertSecurityParams = {
|
|
28
|
+
securityRequirements?: OpenAPIV3_1.SecurityRequirementObject[];
|
|
29
|
+
securitySchemes: OpenAPIV3_1.ComponentsObject['securitySchemes'];
|
|
30
|
+
};
|
|
31
|
+
export declare const convertSecurity: ({ securityRequirements, securitySchemes, }: ConvertSecurityParams) => SecurityOption[];
|
|
32
|
+
type AddSecurityParametersParams = {
|
|
33
|
+
securityScheme: OpenAPIV3_1.SecuritySchemeObject;
|
|
34
|
+
parameterSections: SecurityOption;
|
|
35
|
+
};
|
|
36
|
+
export declare const addSecurityParameters: ({ securityScheme, parameterSections, }: AddSecurityParametersParams) => void;
|
|
37
|
+
export declare const convertBody: (body?: OpenAPIV3_1.RequestBodyObject) => BodySchema;
|
|
38
|
+
export declare const convertResponses: (responses: OpenAPIV3_1.ResponsesObject) => ResponseSchema;
|
|
39
|
+
export declare const convertResponse: (response: OpenAPIV3_1.ResponseObject) => {
|
|
40
|
+
[contentType: string]: DataSchemaArray;
|
|
41
|
+
};
|
|
42
|
+
export declare const convertOpenAPIV3_1ToEndpoint: (spec: OpenAPIV3_1.Document, path: string, method: HttpMethod) => Endpoint | undefined;
|
|
43
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const hexadecimalPattern: RegExp;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { NavigationType } from "../types/navigation";
|
|
2
|
+
import { AnchorsType } from "../types/anchors";
|
|
3
|
+
import { MintValidationResults } from "./common";
|
|
4
|
+
export declare function validateAnchorsWarnings(anchors: AnchorsType | undefined, navigation: NavigationType[] | undefined): MintValidationResults;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { NavigationEntry, NavigationType } from "../types/navigation";
|
|
2
|
+
import { VersionsType } from "../types/versions";
|
|
3
|
+
import { MintValidationResults } from "./common";
|
|
4
|
+
export declare function flattenNavigationVersions(nav: NavigationEntry[], versions?: string[]): string[];
|
|
5
|
+
export declare function validateVersionsInNavigation(navigation: NavigationType[] | undefined, versions?: VersionsType | undefined): MintValidationResults;
|
package/package.json
CHANGED
|
@@ -1,72 +1,74 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@mintlify/validation",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Validates mint.json files",
|
|
5
|
-
"author": "Mintlify, Inc.",
|
|
6
|
-
"repository": {
|
|
7
|
-
"type": "git",
|
|
8
|
-
"url": "https://github.com/mintlify/mint",
|
|
9
|
-
"directory": "packages/mintlify-validation"
|
|
10
|
-
},
|
|
11
|
-
"bugs": {
|
|
12
|
-
"url": "https://github.com/mintlify/mint/issues"
|
|
13
|
-
},
|
|
14
|
-
"license": "Elastic-2.0",
|
|
15
|
-
"keywords": [
|
|
16
|
-
"mintlify",
|
|
17
|
-
"mint",
|
|
18
|
-
"validation"
|
|
19
|
-
],
|
|
20
|
-
"type": "commonjs",
|
|
21
|
-
"publishConfig": {
|
|
22
|
-
"access": "public",
|
|
23
|
-
"registry": "https://registry.npmjs.org/"
|
|
24
|
-
},
|
|
25
|
-
"main": "./dist/index.js",
|
|
26
|
-
"types": "./dist/index.d.ts",
|
|
27
|
-
"files": [
|
|
28
|
-
"dist"
|
|
29
|
-
],
|
|
30
|
-
"jest": {
|
|
31
|
-
"verbose": true,
|
|
32
|
-
"moduleNameMapper": {
|
|
33
|
-
"@/utils/(.*)": "<rootDir>/src/utils/$1",
|
|
34
|
-
"@/schemas/(.*)": "<rootDir>/src/schemas/$1",
|
|
35
|
-
"@/types/(.*)": "<rootDir>/src/types/$1"
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
"scripts": {
|
|
39
|
-
"prepare": "npm run build",
|
|
40
|
-
"build": "webpack",
|
|
41
|
-
"test": "jest",
|
|
42
|
-
"lint": "eslint . --cache"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
"@babel/
|
|
53
|
-
"@
|
|
54
|
-
"@
|
|
55
|
-
"@mintlify/
|
|
56
|
-
"@
|
|
57
|
-
"@
|
|
58
|
-
"@
|
|
59
|
-
"
|
|
60
|
-
"eslint": "
|
|
61
|
-
"eslint
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@mintlify/validation",
|
|
3
|
+
"version": "0.1.40",
|
|
4
|
+
"description": "Validates mint.json files",
|
|
5
|
+
"author": "Mintlify, Inc.",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/mintlify/mint",
|
|
9
|
+
"directory": "packages/mintlify-validation"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/mintlify/mint/issues"
|
|
13
|
+
},
|
|
14
|
+
"license": "Elastic-2.0",
|
|
15
|
+
"keywords": [
|
|
16
|
+
"mintlify",
|
|
17
|
+
"mint",
|
|
18
|
+
"validation"
|
|
19
|
+
],
|
|
20
|
+
"type": "commonjs",
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public",
|
|
23
|
+
"registry": "https://registry.npmjs.org/"
|
|
24
|
+
},
|
|
25
|
+
"main": "./dist/index.js",
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"files": [
|
|
28
|
+
"dist"
|
|
29
|
+
],
|
|
30
|
+
"jest": {
|
|
31
|
+
"verbose": true,
|
|
32
|
+
"moduleNameMapper": {
|
|
33
|
+
"@/utils/(.*)": "<rootDir>/src/utils/$1",
|
|
34
|
+
"@/schemas/(.*)": "<rootDir>/src/schemas/$1",
|
|
35
|
+
"@/types/(.*)": "<rootDir>/src/types/$1"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"prepare": "npm run build",
|
|
40
|
+
"build": "webpack",
|
|
41
|
+
"test": "jest",
|
|
42
|
+
"lint": "eslint . --cache",
|
|
43
|
+
"format": "prettier \"./src/**/*.ts\" --write",
|
|
44
|
+
"format:check": "prettier \"./src/**/*.ts\" --check"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"mathjs": "^11.8.0",
|
|
48
|
+
"zod": "^3.20.6",
|
|
49
|
+
"zod-to-json-schema": "^3.20.3"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@babel/core": "^7.20.2",
|
|
53
|
+
"@babel/preset-env": "^7.20.2",
|
|
54
|
+
"@babel/preset-typescript": "^7.18.6",
|
|
55
|
+
"@mintlify/eslint-config": "1.0.3",
|
|
56
|
+
"@mintlify/eslint-config-typescript": "1.0.7",
|
|
57
|
+
"@mintlify/prettier-config": "1.0.1",
|
|
58
|
+
"@mintlify/ts-config": "1.0.7",
|
|
59
|
+
"@tsconfig/recommended": "1.x",
|
|
60
|
+
"@typescript-eslint/eslint-plugin": "5.x",
|
|
61
|
+
"@typescript-eslint/parser": "5.x",
|
|
62
|
+
"babel-jest": "^29.3.1",
|
|
63
|
+
"eslint": "8.x",
|
|
64
|
+
"eslint-config-prettier": "8.x",
|
|
65
|
+
"eslint-plugin-unused-imports": "2.x",
|
|
66
|
+
"jest": "^29.3.1",
|
|
67
|
+
"openapi-types": "^12.1.0",
|
|
68
|
+
"prettier": "2.x",
|
|
69
|
+
"ts-loader": "^9.4.2",
|
|
70
|
+
"typescript": "^4.8.2",
|
|
71
|
+
"webpack": "^5.75.0",
|
|
72
|
+
"webpack-cli": "^5.0.1"
|
|
73
|
+
}
|
|
74
|
+
}
|