@mintlify/validation 0.1.559 → 0.1.561
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/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/mint-config/schemas/v2/index.d.ts +56 -0
- package/dist/mint-config/schemas/v2/properties/api.d.ts +5 -0
- package/dist/mint-config/schemas/v2/properties/api.js +4 -0
- package/dist/mint-config/schemas/v2/themes/almond.d.ts +7 -0
- package/dist/mint-config/schemas/v2/themes/aspen.d.ts +7 -0
- package/dist/mint-config/schemas/v2/themes/linden.d.ts +7 -0
- package/dist/mint-config/schemas/v2/themes/maple.d.ts +7 -0
- package/dist/mint-config/schemas/v2/themes/mint.d.ts +7 -0
- package/dist/mint-config/schemas/v2/themes/palm.d.ts +7 -0
- package/dist/mint-config/schemas/v2/themes/reusable/index.d.ts +5 -0
- package/dist/mint-config/schemas/v2/themes/willow.d.ts +7 -0
- package/dist/mint-config/validateConfig.d.ts +14 -0
- package/dist/openapi/OpenApiToEndpointConverter.d.ts +38 -0
- package/dist/openapi/OpenApiToEndpointConverter.js +271 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -82,14 +82,17 @@ export declare const mintConfigSchema: z.ZodObject<{
|
|
|
82
82
|
defaults: z.ZodOptional<z.ZodEnum<["required", "all"]>>;
|
|
83
83
|
languages: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
84
84
|
prefill: z.ZodOptional<z.ZodBoolean>;
|
|
85
|
+
autogenerate: z.ZodOptional<z.ZodBoolean>;
|
|
85
86
|
}, "strip", z.ZodTypeAny, {
|
|
86
87
|
languages?: string[] | undefined;
|
|
87
88
|
defaults?: "all" | "required" | undefined;
|
|
88
89
|
prefill?: boolean | undefined;
|
|
90
|
+
autogenerate?: boolean | undefined;
|
|
89
91
|
}, {
|
|
90
92
|
languages?: string[] | undefined;
|
|
91
93
|
defaults?: "all" | "required" | undefined;
|
|
92
94
|
prefill?: boolean | undefined;
|
|
95
|
+
autogenerate?: boolean | undefined;
|
|
93
96
|
}>>;
|
|
94
97
|
mdx: z.ZodOptional<z.ZodObject<{
|
|
95
98
|
auth: z.ZodOptional<z.ZodObject<{
|
|
@@ -136,6 +139,7 @@ export declare const mintConfigSchema: z.ZodObject<{
|
|
|
136
139
|
languages?: string[] | undefined;
|
|
137
140
|
defaults?: "all" | "required" | undefined;
|
|
138
141
|
prefill?: boolean | undefined;
|
|
142
|
+
autogenerate?: boolean | undefined;
|
|
139
143
|
} | undefined;
|
|
140
144
|
mdx?: {
|
|
141
145
|
server?: string | string[] | undefined;
|
|
@@ -164,6 +168,7 @@ export declare const mintConfigSchema: z.ZodObject<{
|
|
|
164
168
|
languages?: string[] | undefined;
|
|
165
169
|
defaults?: "all" | "required" | undefined;
|
|
166
170
|
prefill?: boolean | undefined;
|
|
171
|
+
autogenerate?: boolean | undefined;
|
|
167
172
|
} | undefined;
|
|
168
173
|
mdx?: {
|
|
169
174
|
server?: string | string[] | undefined;
|
|
@@ -1570,6 +1575,7 @@ export declare const mintConfigSchema: z.ZodObject<{
|
|
|
1570
1575
|
languages?: string[] | undefined;
|
|
1571
1576
|
defaults?: "all" | "required" | undefined;
|
|
1572
1577
|
prefill?: boolean | undefined;
|
|
1578
|
+
autogenerate?: boolean | undefined;
|
|
1573
1579
|
} | undefined;
|
|
1574
1580
|
mdx?: {
|
|
1575
1581
|
server?: string | string[] | undefined;
|
|
@@ -1894,6 +1900,7 @@ export declare const mintConfigSchema: z.ZodObject<{
|
|
|
1894
1900
|
languages?: string[] | undefined;
|
|
1895
1901
|
defaults?: "all" | "required" | undefined;
|
|
1896
1902
|
prefill?: boolean | undefined;
|
|
1903
|
+
autogenerate?: boolean | undefined;
|
|
1897
1904
|
} | undefined;
|
|
1898
1905
|
mdx?: {
|
|
1899
1906
|
server?: string | string[] | undefined;
|
|
@@ -82,14 +82,17 @@ export declare const palmConfigSchema: z.ZodObject<{
|
|
|
82
82
|
defaults: z.ZodOptional<z.ZodEnum<["required", "all"]>>;
|
|
83
83
|
languages: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
84
84
|
prefill: z.ZodOptional<z.ZodBoolean>;
|
|
85
|
+
autogenerate: z.ZodOptional<z.ZodBoolean>;
|
|
85
86
|
}, "strip", z.ZodTypeAny, {
|
|
86
87
|
languages?: string[] | undefined;
|
|
87
88
|
defaults?: "all" | "required" | undefined;
|
|
88
89
|
prefill?: boolean | undefined;
|
|
90
|
+
autogenerate?: boolean | undefined;
|
|
89
91
|
}, {
|
|
90
92
|
languages?: string[] | undefined;
|
|
91
93
|
defaults?: "all" | "required" | undefined;
|
|
92
94
|
prefill?: boolean | undefined;
|
|
95
|
+
autogenerate?: boolean | undefined;
|
|
93
96
|
}>>;
|
|
94
97
|
mdx: z.ZodOptional<z.ZodObject<{
|
|
95
98
|
auth: z.ZodOptional<z.ZodObject<{
|
|
@@ -136,6 +139,7 @@ export declare const palmConfigSchema: z.ZodObject<{
|
|
|
136
139
|
languages?: string[] | undefined;
|
|
137
140
|
defaults?: "all" | "required" | undefined;
|
|
138
141
|
prefill?: boolean | undefined;
|
|
142
|
+
autogenerate?: boolean | undefined;
|
|
139
143
|
} | undefined;
|
|
140
144
|
mdx?: {
|
|
141
145
|
server?: string | string[] | undefined;
|
|
@@ -164,6 +168,7 @@ export declare const palmConfigSchema: z.ZodObject<{
|
|
|
164
168
|
languages?: string[] | undefined;
|
|
165
169
|
defaults?: "all" | "required" | undefined;
|
|
166
170
|
prefill?: boolean | undefined;
|
|
171
|
+
autogenerate?: boolean | undefined;
|
|
167
172
|
} | undefined;
|
|
168
173
|
mdx?: {
|
|
169
174
|
server?: string | string[] | undefined;
|
|
@@ -1570,6 +1575,7 @@ export declare const palmConfigSchema: z.ZodObject<{
|
|
|
1570
1575
|
languages?: string[] | undefined;
|
|
1571
1576
|
defaults?: "all" | "required" | undefined;
|
|
1572
1577
|
prefill?: boolean | undefined;
|
|
1578
|
+
autogenerate?: boolean | undefined;
|
|
1573
1579
|
} | undefined;
|
|
1574
1580
|
mdx?: {
|
|
1575
1581
|
server?: string | string[] | undefined;
|
|
@@ -1894,6 +1900,7 @@ export declare const palmConfigSchema: z.ZodObject<{
|
|
|
1894
1900
|
languages?: string[] | undefined;
|
|
1895
1901
|
defaults?: "all" | "required" | undefined;
|
|
1896
1902
|
prefill?: boolean | undefined;
|
|
1903
|
+
autogenerate?: boolean | undefined;
|
|
1897
1904
|
} | undefined;
|
|
1898
1905
|
mdx?: {
|
|
1899
1906
|
server?: string | string[] | undefined;
|
|
@@ -81,14 +81,17 @@ export declare const standardConfigSchema: {
|
|
|
81
81
|
defaults: import("zod").ZodOptional<import("zod").ZodEnum<["required", "all"]>>;
|
|
82
82
|
languages: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString, "many">>;
|
|
83
83
|
prefill: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
84
|
+
autogenerate: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
84
85
|
}, "strip", import("zod").ZodTypeAny, {
|
|
85
86
|
languages?: string[] | undefined;
|
|
86
87
|
defaults?: "all" | "required" | undefined;
|
|
87
88
|
prefill?: boolean | undefined;
|
|
89
|
+
autogenerate?: boolean | undefined;
|
|
88
90
|
}, {
|
|
89
91
|
languages?: string[] | undefined;
|
|
90
92
|
defaults?: "all" | "required" | undefined;
|
|
91
93
|
prefill?: boolean | undefined;
|
|
94
|
+
autogenerate?: boolean | undefined;
|
|
92
95
|
}>>;
|
|
93
96
|
mdx: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
94
97
|
auth: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
@@ -135,6 +138,7 @@ export declare const standardConfigSchema: {
|
|
|
135
138
|
languages?: string[] | undefined;
|
|
136
139
|
defaults?: "all" | "required" | undefined;
|
|
137
140
|
prefill?: boolean | undefined;
|
|
141
|
+
autogenerate?: boolean | undefined;
|
|
138
142
|
} | undefined;
|
|
139
143
|
mdx?: {
|
|
140
144
|
server?: string | string[] | undefined;
|
|
@@ -163,6 +167,7 @@ export declare const standardConfigSchema: {
|
|
|
163
167
|
languages?: string[] | undefined;
|
|
164
168
|
defaults?: "all" | "required" | undefined;
|
|
165
169
|
prefill?: boolean | undefined;
|
|
170
|
+
autogenerate?: boolean | undefined;
|
|
166
171
|
} | undefined;
|
|
167
172
|
mdx?: {
|
|
168
173
|
server?: string | string[] | undefined;
|
|
@@ -82,14 +82,17 @@ export declare const willowConfigSchema: z.ZodObject<{
|
|
|
82
82
|
defaults: z.ZodOptional<z.ZodEnum<["required", "all"]>>;
|
|
83
83
|
languages: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
84
84
|
prefill: z.ZodOptional<z.ZodBoolean>;
|
|
85
|
+
autogenerate: z.ZodOptional<z.ZodBoolean>;
|
|
85
86
|
}, "strip", z.ZodTypeAny, {
|
|
86
87
|
languages?: string[] | undefined;
|
|
87
88
|
defaults?: "all" | "required" | undefined;
|
|
88
89
|
prefill?: boolean | undefined;
|
|
90
|
+
autogenerate?: boolean | undefined;
|
|
89
91
|
}, {
|
|
90
92
|
languages?: string[] | undefined;
|
|
91
93
|
defaults?: "all" | "required" | undefined;
|
|
92
94
|
prefill?: boolean | undefined;
|
|
95
|
+
autogenerate?: boolean | undefined;
|
|
93
96
|
}>>;
|
|
94
97
|
mdx: z.ZodOptional<z.ZodObject<{
|
|
95
98
|
auth: z.ZodOptional<z.ZodObject<{
|
|
@@ -136,6 +139,7 @@ export declare const willowConfigSchema: z.ZodObject<{
|
|
|
136
139
|
languages?: string[] | undefined;
|
|
137
140
|
defaults?: "all" | "required" | undefined;
|
|
138
141
|
prefill?: boolean | undefined;
|
|
142
|
+
autogenerate?: boolean | undefined;
|
|
139
143
|
} | undefined;
|
|
140
144
|
mdx?: {
|
|
141
145
|
server?: string | string[] | undefined;
|
|
@@ -164,6 +168,7 @@ export declare const willowConfigSchema: z.ZodObject<{
|
|
|
164
168
|
languages?: string[] | undefined;
|
|
165
169
|
defaults?: "all" | "required" | undefined;
|
|
166
170
|
prefill?: boolean | undefined;
|
|
171
|
+
autogenerate?: boolean | undefined;
|
|
167
172
|
} | undefined;
|
|
168
173
|
mdx?: {
|
|
169
174
|
server?: string | string[] | undefined;
|
|
@@ -1570,6 +1575,7 @@ export declare const willowConfigSchema: z.ZodObject<{
|
|
|
1570
1575
|
languages?: string[] | undefined;
|
|
1571
1576
|
defaults?: "all" | "required" | undefined;
|
|
1572
1577
|
prefill?: boolean | undefined;
|
|
1578
|
+
autogenerate?: boolean | undefined;
|
|
1573
1579
|
} | undefined;
|
|
1574
1580
|
mdx?: {
|
|
1575
1581
|
server?: string | string[] | undefined;
|
|
@@ -1894,6 +1900,7 @@ export declare const willowConfigSchema: z.ZodObject<{
|
|
|
1894
1900
|
languages?: string[] | undefined;
|
|
1895
1901
|
defaults?: "all" | "required" | undefined;
|
|
1896
1902
|
prefill?: boolean | undefined;
|
|
1903
|
+
autogenerate?: boolean | undefined;
|
|
1897
1904
|
} | undefined;
|
|
1898
1905
|
mdx?: {
|
|
1899
1906
|
server?: string | string[] | undefined;
|
|
@@ -615,6 +615,7 @@ export declare function validateDocsConfig(value: unknown): z.SafeParseError<{
|
|
|
615
615
|
languages?: string[] | undefined;
|
|
616
616
|
defaults?: "all" | "required" | undefined;
|
|
617
617
|
prefill?: boolean | undefined;
|
|
618
|
+
autogenerate?: boolean | undefined;
|
|
618
619
|
} | undefined;
|
|
619
620
|
mdx?: {
|
|
620
621
|
server?: string | string[] | undefined;
|
|
@@ -939,6 +940,7 @@ export declare function validateDocsConfig(value: unknown): z.SafeParseError<{
|
|
|
939
940
|
languages?: string[] | undefined;
|
|
940
941
|
defaults?: "all" | "required" | undefined;
|
|
941
942
|
prefill?: boolean | undefined;
|
|
943
|
+
autogenerate?: boolean | undefined;
|
|
942
944
|
} | undefined;
|
|
943
945
|
mdx?: {
|
|
944
946
|
server?: string | string[] | undefined;
|
|
@@ -1263,6 +1265,7 @@ export declare function validateDocsConfig(value: unknown): z.SafeParseError<{
|
|
|
1263
1265
|
languages?: string[] | undefined;
|
|
1264
1266
|
defaults?: "all" | "required" | undefined;
|
|
1265
1267
|
prefill?: boolean | undefined;
|
|
1268
|
+
autogenerate?: boolean | undefined;
|
|
1266
1269
|
} | undefined;
|
|
1267
1270
|
mdx?: {
|
|
1268
1271
|
server?: string | string[] | undefined;
|
|
@@ -1587,6 +1590,7 @@ export declare function validateDocsConfig(value: unknown): z.SafeParseError<{
|
|
|
1587
1590
|
languages?: string[] | undefined;
|
|
1588
1591
|
defaults?: "all" | "required" | undefined;
|
|
1589
1592
|
prefill?: boolean | undefined;
|
|
1593
|
+
autogenerate?: boolean | undefined;
|
|
1590
1594
|
} | undefined;
|
|
1591
1595
|
mdx?: {
|
|
1592
1596
|
server?: string | string[] | undefined;
|
|
@@ -1911,6 +1915,7 @@ export declare function validateDocsConfig(value: unknown): z.SafeParseError<{
|
|
|
1911
1915
|
languages?: string[] | undefined;
|
|
1912
1916
|
defaults?: "all" | "required" | undefined;
|
|
1913
1917
|
prefill?: boolean | undefined;
|
|
1918
|
+
autogenerate?: boolean | undefined;
|
|
1914
1919
|
} | undefined;
|
|
1915
1920
|
mdx?: {
|
|
1916
1921
|
server?: string | string[] | undefined;
|
|
@@ -2235,6 +2240,7 @@ export declare function validateDocsConfig(value: unknown): z.SafeParseError<{
|
|
|
2235
2240
|
languages?: string[] | undefined;
|
|
2236
2241
|
defaults?: "all" | "required" | undefined;
|
|
2237
2242
|
prefill?: boolean | undefined;
|
|
2243
|
+
autogenerate?: boolean | undefined;
|
|
2238
2244
|
} | undefined;
|
|
2239
2245
|
mdx?: {
|
|
2240
2246
|
server?: string | string[] | undefined;
|
|
@@ -2559,6 +2565,7 @@ export declare function validateDocsConfig(value: unknown): z.SafeParseError<{
|
|
|
2559
2565
|
languages?: string[] | undefined;
|
|
2560
2566
|
defaults?: "all" | "required" | undefined;
|
|
2561
2567
|
prefill?: boolean | undefined;
|
|
2568
|
+
autogenerate?: boolean | undefined;
|
|
2562
2569
|
} | undefined;
|
|
2563
2570
|
mdx?: {
|
|
2564
2571
|
server?: string | string[] | undefined;
|
|
@@ -2886,6 +2893,7 @@ export declare function validateDocsConfig(value: unknown): z.SafeParseError<{
|
|
|
2886
2893
|
languages?: string[] | undefined;
|
|
2887
2894
|
defaults?: "all" | "required" | undefined;
|
|
2888
2895
|
prefill?: boolean | undefined;
|
|
2896
|
+
autogenerate?: boolean | undefined;
|
|
2889
2897
|
} | undefined;
|
|
2890
2898
|
mdx?: {
|
|
2891
2899
|
server?: string | string[] | undefined;
|
|
@@ -3210,6 +3218,7 @@ export declare function validateDocsConfig(value: unknown): z.SafeParseError<{
|
|
|
3210
3218
|
languages?: string[] | undefined;
|
|
3211
3219
|
defaults?: "all" | "required" | undefined;
|
|
3212
3220
|
prefill?: boolean | undefined;
|
|
3221
|
+
autogenerate?: boolean | undefined;
|
|
3213
3222
|
} | undefined;
|
|
3214
3223
|
mdx?: {
|
|
3215
3224
|
server?: string | string[] | undefined;
|
|
@@ -3534,6 +3543,7 @@ export declare function validateDocsConfig(value: unknown): z.SafeParseError<{
|
|
|
3534
3543
|
languages?: string[] | undefined;
|
|
3535
3544
|
defaults?: "all" | "required" | undefined;
|
|
3536
3545
|
prefill?: boolean | undefined;
|
|
3546
|
+
autogenerate?: boolean | undefined;
|
|
3537
3547
|
} | undefined;
|
|
3538
3548
|
mdx?: {
|
|
3539
3549
|
server?: string | string[] | undefined;
|
|
@@ -3858,6 +3868,7 @@ export declare function validateDocsConfig(value: unknown): z.SafeParseError<{
|
|
|
3858
3868
|
languages?: string[] | undefined;
|
|
3859
3869
|
defaults?: "all" | "required" | undefined;
|
|
3860
3870
|
prefill?: boolean | undefined;
|
|
3871
|
+
autogenerate?: boolean | undefined;
|
|
3861
3872
|
} | undefined;
|
|
3862
3873
|
mdx?: {
|
|
3863
3874
|
server?: string | string[] | undefined;
|
|
@@ -4182,6 +4193,7 @@ export declare function validateDocsConfig(value: unknown): z.SafeParseError<{
|
|
|
4182
4193
|
languages?: string[] | undefined;
|
|
4183
4194
|
defaults?: "all" | "required" | undefined;
|
|
4184
4195
|
prefill?: boolean | undefined;
|
|
4196
|
+
autogenerate?: boolean | undefined;
|
|
4185
4197
|
} | undefined;
|
|
4186
4198
|
mdx?: {
|
|
4187
4199
|
server?: string | string[] | undefined;
|
|
@@ -4506,6 +4518,7 @@ export declare function validateDocsConfig(value: unknown): z.SafeParseError<{
|
|
|
4506
4518
|
languages?: string[] | undefined;
|
|
4507
4519
|
defaults?: "all" | "required" | undefined;
|
|
4508
4520
|
prefill?: boolean | undefined;
|
|
4521
|
+
autogenerate?: boolean | undefined;
|
|
4509
4522
|
} | undefined;
|
|
4510
4523
|
mdx?: {
|
|
4511
4524
|
server?: string | string[] | undefined;
|
|
@@ -4830,6 +4843,7 @@ export declare function validateDocsConfig(value: unknown): z.SafeParseError<{
|
|
|
4830
4843
|
languages?: string[] | undefined;
|
|
4831
4844
|
defaults?: "all" | "required" | undefined;
|
|
4832
4845
|
prefill?: boolean | undefined;
|
|
4846
|
+
autogenerate?: boolean | undefined;
|
|
4833
4847
|
} | undefined;
|
|
4834
4848
|
mdx?: {
|
|
4835
4849
|
server?: string | string[] | undefined;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { OpenAPIV3_1 } from 'openapi-types';
|
|
2
|
+
import { BaseConverter } from './BaseConverter.js';
|
|
3
|
+
import type { ContentSchema, DataSchemaArray, Endpoint, ExampleSchema, HttpMethod, IncrementalDataSchemaArray, ParameterSections, ResponseSchema } from './types/endpoint.js';
|
|
4
|
+
import { EndpointLocation } from './types/endpoint.js';
|
|
5
|
+
export declare abstract class BaseOpenApiToEndpointConverter<D extends DataSchemaArray | IncrementalDataSchemaArray> extends BaseConverter {
|
|
6
|
+
readonly document: OpenAPIV3_1.Document;
|
|
7
|
+
readonly path: string;
|
|
8
|
+
readonly method: HttpMethod;
|
|
9
|
+
readonly safeParse: boolean;
|
|
10
|
+
protected pathObject: OpenAPIV3_1.PathItemObject;
|
|
11
|
+
protected operationObject: OpenAPIV3_1.OperationObject;
|
|
12
|
+
protected location: EndpointLocation;
|
|
13
|
+
protected constructor(document: OpenAPIV3_1.Document, path: string, method: HttpMethod, safeParse?: boolean);
|
|
14
|
+
protected convert(): Endpoint<D>;
|
|
15
|
+
abstract convertParameters(): ParameterSections<D>;
|
|
16
|
+
abstract convertBody(): Record<string, ContentSchema<D>>;
|
|
17
|
+
abstract convertResponses(): ResponseSchema<D>;
|
|
18
|
+
protected convertExamples(examples: Record<string, OpenAPIV3_1.ExampleObject> | undefined, example: unknown | undefined, schemaArray: DataSchemaArray): Record<string, ExampleSchema>;
|
|
19
|
+
private convertCodeSamples;
|
|
20
|
+
private getXmcp;
|
|
21
|
+
private getXmint;
|
|
22
|
+
}
|
|
23
|
+
export declare class OpenApiToEndpointConverter extends BaseOpenApiToEndpointConverter<DataSchemaArray> {
|
|
24
|
+
convertBody(): Record<string, ContentSchema<DataSchemaArray>>;
|
|
25
|
+
convertResponses(): ResponseSchema<DataSchemaArray>;
|
|
26
|
+
convertContent(debugPath: string[], content: Record<string, OpenAPIV3_1.MediaTypeObject> | undefined, location: 'request' | 'response', required?: boolean, description?: string): Record<string, ContentSchema<DataSchemaArray>>;
|
|
27
|
+
convertParameters(): ParameterSections<DataSchemaArray>;
|
|
28
|
+
static convert(spec: OpenAPIV3_1.Document, path: string, method: HttpMethod, safeParse?: boolean): Endpoint<DataSchemaArray>;
|
|
29
|
+
}
|
|
30
|
+
export declare class OpenApiToIncrementalEndpointConverter extends BaseOpenApiToEndpointConverter<IncrementalDataSchemaArray> {
|
|
31
|
+
readonly rawDocument: OpenAPIV3_1.Document;
|
|
32
|
+
private constructor();
|
|
33
|
+
convertParameters(): ParameterSections<IncrementalDataSchemaArray>;
|
|
34
|
+
convertBody(): Record<string, ContentSchema<IncrementalDataSchemaArray>>;
|
|
35
|
+
convertResponses(): ResponseSchema<IncrementalDataSchemaArray>;
|
|
36
|
+
convertContent(debugPath: string[], rawContent: Record<string, OpenAPIV3_1.MediaTypeObject> | undefined, dereferencedContent: Record<string, OpenAPIV3_1.MediaTypeObject> | undefined, location: 'request' | 'response', required?: boolean, description?: string): Record<string, ContentSchema<IncrementalDataSchemaArray>>;
|
|
37
|
+
static convert(rawDocument: OpenAPIV3_1.Document, resolvedDocument: OpenAPIV3_1.Document, path: string, method: HttpMethod, safeParse?: boolean): Endpoint<IncrementalDataSchemaArray>;
|
|
38
|
+
}
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import { type } from 'arktype';
|
|
2
|
+
import { BaseConverter } from './BaseConverter.js';
|
|
3
|
+
import { generateFirstIncrementalSchema } from './IncrementalEvaluator.js';
|
|
4
|
+
import { IncrementalParametersConverter, ParametersConverter } from './ParametersConverter.js';
|
|
5
|
+
import { SchemaConverter } from './SchemaConverter.js';
|
|
6
|
+
import { SecurityConverter } from './SecurityConverter.js';
|
|
7
|
+
import { ServersConverter } from './ServersConverter.js';
|
|
8
|
+
import { InvalidSchemaError } from './errors.js';
|
|
9
|
+
import { generateExampleFromSchema } from './generateExampleFromSchema.js';
|
|
10
|
+
import { EndpointLocation, XMcpType, XMintType } from './types/endpoint.js';
|
|
11
|
+
import { dereference } from './utils.js';
|
|
12
|
+
export class BaseOpenApiToEndpointConverter extends BaseConverter {
|
|
13
|
+
constructor(document, path, method, safeParse = false) {
|
|
14
|
+
super(safeParse);
|
|
15
|
+
this.document = document;
|
|
16
|
+
this.path = path;
|
|
17
|
+
this.method = method;
|
|
18
|
+
this.safeParse = safeParse;
|
|
19
|
+
this.location = new EndpointLocation(document, path);
|
|
20
|
+
const paths = this.location.getEndpointPaths();
|
|
21
|
+
if (paths === undefined) {
|
|
22
|
+
throw new InvalidSchemaError(['#'], `${this.location.type} not defined`);
|
|
23
|
+
}
|
|
24
|
+
const pathObject = this.location.getEndpoint();
|
|
25
|
+
if (pathObject === undefined) {
|
|
26
|
+
throw new InvalidSchemaError(['#', this.location.path], `${this.location.type} not defined: ${this.path}`);
|
|
27
|
+
}
|
|
28
|
+
this.pathObject = pathObject;
|
|
29
|
+
const operationObject = pathObject[this.method];
|
|
30
|
+
if (operationObject === undefined) {
|
|
31
|
+
throw new InvalidSchemaError(['#', this.location.path, this.path], `operation does not exist: ${this.method}`);
|
|
32
|
+
}
|
|
33
|
+
this.operationObject = operationObject;
|
|
34
|
+
}
|
|
35
|
+
convert() {
|
|
36
|
+
var _a, _b, _c, _d, _e, _f;
|
|
37
|
+
const securityRequirements = this.location.type === 'webhook'
|
|
38
|
+
? this.operationObject.security
|
|
39
|
+
: (_a = this.operationObject.security) !== null && _a !== void 0 ? _a : this.document.security;
|
|
40
|
+
const securitySchemes = (_b = this.document.components) === null || _b === void 0 ? void 0 : _b.securitySchemes;
|
|
41
|
+
const security = SecurityConverter.convert(securityRequirements, securitySchemes, this.safeParse);
|
|
42
|
+
const parameters = this.convertParameters();
|
|
43
|
+
const servers = ServersConverter.convert((_d = (_c = this.operationObject.servers) !== null && _c !== void 0 ? _c : this.pathObject.servers) !== null && _d !== void 0 ? _d : this.document.servers);
|
|
44
|
+
// title is a bit too specific to take from the path object
|
|
45
|
+
const title = this.operationObject.summary;
|
|
46
|
+
const description = (_e = this.operationObject.description) !== null && _e !== void 0 ? _e : this.pathObject.description;
|
|
47
|
+
const body = this.convertBody();
|
|
48
|
+
const deprecated = !!this.operationObject.deprecated;
|
|
49
|
+
const codeSamples = this.convertCodeSamples(['#', this.location.path, this.path, this.method], this.operationObject);
|
|
50
|
+
const rawXmcp = this.getXmcp(this.operationObject);
|
|
51
|
+
const xMint = this.getXmint(this.operationObject);
|
|
52
|
+
const xMcp = (_f = xMint === null || xMint === void 0 ? void 0 : xMint.mcp) !== null && _f !== void 0 ? _f : rawXmcp;
|
|
53
|
+
const response = this.convertResponses();
|
|
54
|
+
return {
|
|
55
|
+
title,
|
|
56
|
+
description,
|
|
57
|
+
path: this.path,
|
|
58
|
+
method: this.method,
|
|
59
|
+
servers,
|
|
60
|
+
request: {
|
|
61
|
+
security,
|
|
62
|
+
parameters,
|
|
63
|
+
body,
|
|
64
|
+
codeSamples,
|
|
65
|
+
},
|
|
66
|
+
response,
|
|
67
|
+
deprecated,
|
|
68
|
+
type: this.location.type,
|
|
69
|
+
xMcp,
|
|
70
|
+
xMint,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
convertExamples(examples, example, schemaArray) {
|
|
74
|
+
if (examples && Object.values(examples).some(({ value }) => value !== undefined)) {
|
|
75
|
+
return Object.fromEntries(Object.entries(examples)
|
|
76
|
+
.filter(([_, { value }]) => value !== undefined)
|
|
77
|
+
.map(([key, example]) => [
|
|
78
|
+
key,
|
|
79
|
+
{
|
|
80
|
+
summary: example.summary,
|
|
81
|
+
description: example.description,
|
|
82
|
+
value: example.value,
|
|
83
|
+
},
|
|
84
|
+
]));
|
|
85
|
+
}
|
|
86
|
+
if (example !== undefined) {
|
|
87
|
+
return { example: { value: example } };
|
|
88
|
+
}
|
|
89
|
+
return { example: { value: generateExampleFromSchema(schemaArray[0]) } };
|
|
90
|
+
}
|
|
91
|
+
convertCodeSamples(debugPath, operation) {
|
|
92
|
+
let key;
|
|
93
|
+
let rawCodeSamples;
|
|
94
|
+
if ('x-codeSamples' in operation) {
|
|
95
|
+
rawCodeSamples = operation['x-codeSamples'];
|
|
96
|
+
key = 'x-codeSamples';
|
|
97
|
+
}
|
|
98
|
+
else if ('x-code-samples' in operation) {
|
|
99
|
+
rawCodeSamples = operation['x-code-samples'];
|
|
100
|
+
key = 'x-code-samples';
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
if (!Array.isArray(rawCodeSamples)) {
|
|
106
|
+
this.handleNewError(InvalidSchemaError, [...debugPath, key], `${key} must be an array`);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const codeSamples = [];
|
|
110
|
+
rawCodeSamples.forEach((codeSample) => {
|
|
111
|
+
if (!codeSample ||
|
|
112
|
+
typeof codeSample !== 'object' ||
|
|
113
|
+
!('source' in codeSample) ||
|
|
114
|
+
typeof codeSample.source !== 'string' ||
|
|
115
|
+
!('lang' in codeSample) ||
|
|
116
|
+
typeof codeSample.lang !== 'string') {
|
|
117
|
+
this.handleNewError(InvalidSchemaError, [...debugPath, key], 'invalid code sample');
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
codeSamples.push({
|
|
121
|
+
label: 'label' in codeSample && typeof codeSample.label === 'string'
|
|
122
|
+
? codeSample.label
|
|
123
|
+
: undefined,
|
|
124
|
+
lang: codeSample['lang'],
|
|
125
|
+
source: codeSample['source'],
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
return codeSamples;
|
|
129
|
+
}
|
|
130
|
+
getXmcp(operation) {
|
|
131
|
+
if ('x-mcp' in operation &&
|
|
132
|
+
typeof operation['x-mcp'] === 'object' &&
|
|
133
|
+
operation['x-mcp'] !== null) {
|
|
134
|
+
const xMcp = XMcpType(operation['x-mcp']);
|
|
135
|
+
return xMcp instanceof type.errors ? undefined : xMcp;
|
|
136
|
+
}
|
|
137
|
+
return undefined;
|
|
138
|
+
}
|
|
139
|
+
getXmint(operation) {
|
|
140
|
+
if ('x-mint' in operation &&
|
|
141
|
+
typeof operation['x-mint'] === 'object' &&
|
|
142
|
+
operation['x-mint'] !== null) {
|
|
143
|
+
const xMint = XMintType(operation['x-mint']);
|
|
144
|
+
return xMint instanceof type.errors ? undefined : xMint;
|
|
145
|
+
}
|
|
146
|
+
return undefined;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
export class OpenApiToEndpointConverter extends BaseOpenApiToEndpointConverter {
|
|
150
|
+
convertBody() {
|
|
151
|
+
const requestBody = this.operationObject.requestBody;
|
|
152
|
+
return this.convertContent(['#', this.location.path, this.path, this.method, 'requestBody', 'content'], requestBody === null || requestBody === void 0 ? void 0 : requestBody.content, 'request', requestBody === null || requestBody === void 0 ? void 0 : requestBody.required, requestBody === null || requestBody === void 0 ? void 0 : requestBody.description);
|
|
153
|
+
}
|
|
154
|
+
convertResponses() {
|
|
155
|
+
const responses = this.operationObject.responses;
|
|
156
|
+
if (!responses)
|
|
157
|
+
return {};
|
|
158
|
+
const newEntries = Object.entries(responses).map(([statusCode, response]) => [
|
|
159
|
+
statusCode,
|
|
160
|
+
this.convertContent(['#', this.location.path, this.path, this.method, 'responses', statusCode, 'content'], response.content, 'response', undefined, response.description),
|
|
161
|
+
]);
|
|
162
|
+
return Object.fromEntries(newEntries);
|
|
163
|
+
}
|
|
164
|
+
convertContent(debugPath, content, location, required, description) {
|
|
165
|
+
if (content === undefined) {
|
|
166
|
+
return {};
|
|
167
|
+
}
|
|
168
|
+
const newEntries = Object.entries(content).map(([contentType, mediaObject]) => {
|
|
169
|
+
const schemaArray = SchemaConverter.convert({
|
|
170
|
+
schema: mediaObject.schema,
|
|
171
|
+
path: [...debugPath, contentType, 'schema'],
|
|
172
|
+
required,
|
|
173
|
+
location,
|
|
174
|
+
contentType,
|
|
175
|
+
safeParse: this.safeParse,
|
|
176
|
+
});
|
|
177
|
+
const examples = this.convertExamples(mediaObject.examples, mediaObject.example, schemaArray);
|
|
178
|
+
return [contentType, { schemaArray, examples, description }];
|
|
179
|
+
});
|
|
180
|
+
return Object.fromEntries(newEntries);
|
|
181
|
+
}
|
|
182
|
+
convertParameters() {
|
|
183
|
+
const pathParameters = this.pathObject.parameters;
|
|
184
|
+
const operationParameters = this.operationObject.parameters;
|
|
185
|
+
return ParametersConverter.convert(this.method, pathParameters, operationParameters, ['#', this.location.path, this.path], this.safeParse);
|
|
186
|
+
}
|
|
187
|
+
static convert(spec, path, method, safeParse) {
|
|
188
|
+
return new OpenApiToEndpointConverter(spec, path, method, safeParse).convert();
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
export class OpenApiToIncrementalEndpointConverter extends BaseOpenApiToEndpointConverter {
|
|
192
|
+
constructor(rawDocument, document, path, method, safeParse = false) {
|
|
193
|
+
super(document, path, method, safeParse);
|
|
194
|
+
this.rawDocument = rawDocument;
|
|
195
|
+
this.location = new EndpointLocation(rawDocument, path);
|
|
196
|
+
}
|
|
197
|
+
convertParameters() {
|
|
198
|
+
var _a;
|
|
199
|
+
const path = this.location.getEndpoint();
|
|
200
|
+
const pathParameters = path === null || path === void 0 ? void 0 : path.parameters;
|
|
201
|
+
const operationParameters = (_a = path === null || path === void 0 ? void 0 : path[this.method]) === null || _a === void 0 ? void 0 : _a.parameters;
|
|
202
|
+
return IncrementalParametersConverter.convert(this.rawDocument, this.method, pathParameters, operationParameters, ['#', this.location.path, this.path], this.safeParse);
|
|
203
|
+
}
|
|
204
|
+
convertBody() {
|
|
205
|
+
var _a, _b;
|
|
206
|
+
const path = this.location.getEndpoint();
|
|
207
|
+
let rawRequestBody = (_a = path === null || path === void 0 ? void 0 : path[this.method]) === null || _a === void 0 ? void 0 : _a.requestBody;
|
|
208
|
+
if (rawRequestBody && '$ref' in rawRequestBody) {
|
|
209
|
+
rawRequestBody = dereference('requestBodies', rawRequestBody.$ref, (_b = this.rawDocument.components) === null || _b === void 0 ? void 0 : _b.requestBodies);
|
|
210
|
+
}
|
|
211
|
+
if (!rawRequestBody || '$ref' in rawRequestBody)
|
|
212
|
+
return {};
|
|
213
|
+
const requestBody = this.operationObject.requestBody;
|
|
214
|
+
return this.convertContent(['#', this.location.path, this.path, this.method, 'requestBody', 'content'], rawRequestBody.content, requestBody === null || requestBody === void 0 ? void 0 : requestBody.content, 'request', requestBody === null || requestBody === void 0 ? void 0 : requestBody.required, requestBody === null || requestBody === void 0 ? void 0 : requestBody.description);
|
|
215
|
+
}
|
|
216
|
+
convertResponses() {
|
|
217
|
+
var _a;
|
|
218
|
+
const path = this.location.getEndpoint();
|
|
219
|
+
const rawResponses = (_a = path === null || path === void 0 ? void 0 : path[this.method]) === null || _a === void 0 ? void 0 : _a.responses;
|
|
220
|
+
if (!rawResponses)
|
|
221
|
+
return {};
|
|
222
|
+
const newEntries = Object.entries(rawResponses).map(([statusCode, rawResponse]) => {
|
|
223
|
+
var _a, _b;
|
|
224
|
+
if ('$ref' in rawResponse) {
|
|
225
|
+
const dereferencedRes = dereference('responses', rawResponse.$ref, (_a = this.rawDocument.components) === null || _a === void 0 ? void 0 : _a.responses);
|
|
226
|
+
if (!dereferencedRes || '$ref' in dereferencedRes)
|
|
227
|
+
throw Error();
|
|
228
|
+
rawResponse = dereferencedRes;
|
|
229
|
+
}
|
|
230
|
+
const response = (_b = this.operationObject.responses) === null || _b === void 0 ? void 0 : _b[statusCode];
|
|
231
|
+
return [
|
|
232
|
+
statusCode,
|
|
233
|
+
this.convertContent(['#', this.location.path, this.path, this.method, 'responses', statusCode, 'content'], rawResponse.content, response === null || response === void 0 ? void 0 : response.content, 'response', undefined, response === null || response === void 0 ? void 0 : response.description),
|
|
234
|
+
];
|
|
235
|
+
});
|
|
236
|
+
return Object.fromEntries(newEntries);
|
|
237
|
+
}
|
|
238
|
+
convertContent(debugPath, rawContent, dereferencedContent, location, required, description) {
|
|
239
|
+
if (!rawContent || !dereferencedContent) {
|
|
240
|
+
if (description) {
|
|
241
|
+
return {
|
|
242
|
+
'_mintlify/placeholder': {
|
|
243
|
+
schemaArray: [{ type: 'any', description }],
|
|
244
|
+
examples: {},
|
|
245
|
+
description,
|
|
246
|
+
},
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
return {};
|
|
250
|
+
}
|
|
251
|
+
const newEntries = Object.entries(rawContent).map(([contentType, mediaObject]) => {
|
|
252
|
+
var _a;
|
|
253
|
+
const incrementalSchemaArray = generateFirstIncrementalSchema(mediaObject.schema, (_a = this.rawDocument.components) === null || _a === void 0 ? void 0 : _a.schemas, required, location, contentType);
|
|
254
|
+
const dereferencedMediaObject = dereferencedContent[contentType];
|
|
255
|
+
const schemaArray = SchemaConverter.convert({
|
|
256
|
+
schema: dereferencedMediaObject === null || dereferencedMediaObject === void 0 ? void 0 : dereferencedMediaObject.schema,
|
|
257
|
+
path: [...debugPath, contentType, 'schema'],
|
|
258
|
+
required,
|
|
259
|
+
location,
|
|
260
|
+
contentType,
|
|
261
|
+
safeParse: this.safeParse,
|
|
262
|
+
});
|
|
263
|
+
const examples = this.convertExamples(dereferencedMediaObject === null || dereferencedMediaObject === void 0 ? void 0 : dereferencedMediaObject.examples, dereferencedMediaObject === null || dereferencedMediaObject === void 0 ? void 0 : dereferencedMediaObject.example, schemaArray);
|
|
264
|
+
return [contentType, { schemaArray: incrementalSchemaArray, examples, description }];
|
|
265
|
+
});
|
|
266
|
+
return Object.fromEntries(newEntries);
|
|
267
|
+
}
|
|
268
|
+
static convert(rawDocument, resolvedDocument, path, method, safeParse) {
|
|
269
|
+
return new OpenApiToIncrementalEndpointConverter(rawDocument, resolvedDocument, path, method, safeParse).convert();
|
|
270
|
+
}
|
|
271
|
+
}
|