@mintlify/validation 0.1.922 → 0.1.924
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/mint-config/schemas/v2/properties/navigation/divisionNav.d.ts +8 -8
- package/dist/mint-config/schemas/v2/properties/navigation/groups.d.ts +908 -4
- package/dist/mint-config/schemas/v2/properties/navigation/index.d.ts +3696 -60
- package/dist/mint-config/schemas/v2/properties/navigation/pages.d.ts +908 -4
- package/dist/mint-config/schemas/v2/properties/reusable/page.d.ts +2 -0
- package/dist/mint-config/schemas/v2/properties/reusable/page.js +23 -0
- package/dist/openapi/OpenApiToEndpointConverter.d.ts +1 -1
- package/dist/openapi/OpenApiToEndpointConverter.js +4 -4
- package/dist/openapi/generateExampleFromSchema.d.ts +1 -1
- package/dist/openapi/generateExampleFromSchema.js +26 -6
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -644,3 +644,5 @@ export declare const decoratedPageSchema: z.ZodObject<{
|
|
|
644
644
|
}>>;
|
|
645
645
|
}, z.ZodTypeAny, "passthrough">>;
|
|
646
646
|
export type DecoratedPageConfig = z.input<typeof decoratedPageSchema>;
|
|
647
|
+
export declare const CLIENT_NAV_PAGE_FIELDS: readonly ["href", "title", "hidden", "groups", "sidebarTitle", "url", "icon", "iconType", "tag", "api", "openapi", "asyncapi", "graphql", "deprecated", "hideApiMarker", "mode", "playground", "version"];
|
|
648
|
+
export type ClientNavPage = Pick<DecoratedPageConfig, (typeof CLIENT_NAV_PAGE_FIELDS)[number] | 'description'>;
|
|
@@ -70,3 +70,26 @@ export const decoratedPageSchema = z
|
|
|
70
70
|
})
|
|
71
71
|
.passthrough()
|
|
72
72
|
.describe('page metadata tags in the navigation');
|
|
73
|
+
function pageFieldAllowlist(fields) {
|
|
74
|
+
return fields;
|
|
75
|
+
}
|
|
76
|
+
export const CLIENT_NAV_PAGE_FIELDS = pageFieldAllowlist([
|
|
77
|
+
'href',
|
|
78
|
+
'title',
|
|
79
|
+
'hidden',
|
|
80
|
+
'groups',
|
|
81
|
+
'sidebarTitle',
|
|
82
|
+
'url',
|
|
83
|
+
'icon',
|
|
84
|
+
'iconType',
|
|
85
|
+
'tag',
|
|
86
|
+
'api',
|
|
87
|
+
'openapi',
|
|
88
|
+
'asyncapi',
|
|
89
|
+
'graphql',
|
|
90
|
+
'deprecated',
|
|
91
|
+
'hideApiMarker',
|
|
92
|
+
'mode',
|
|
93
|
+
'playground',
|
|
94
|
+
'version',
|
|
95
|
+
]);
|
|
@@ -15,7 +15,7 @@ export declare abstract class BaseOpenApiToEndpointConverter<D extends DataSchem
|
|
|
15
15
|
abstract convertParameters(): ParameterSections<D>;
|
|
16
16
|
abstract convertBody(): Record<string, ContentSchema<D>>;
|
|
17
17
|
abstract convertResponses(): ResponseSchema<D>;
|
|
18
|
-
protected convertExamples(examples: Record<string, OpenAPIV3_1.ExampleObject> | undefined, example: unknown | undefined, schemaArray: DataSchemaArray): Record<string, ExampleSchema>;
|
|
18
|
+
protected convertExamples(examples: Record<string, OpenAPIV3_1.ExampleObject> | undefined, example: unknown | undefined, schemaArray: DataSchemaArray, location: 'request' | 'response'): Record<string, ExampleSchema>;
|
|
19
19
|
private convertCodeSamples;
|
|
20
20
|
private getXmcp;
|
|
21
21
|
private getXmint;
|
|
@@ -75,7 +75,7 @@ export class BaseOpenApiToEndpointConverter extends BaseConverter {
|
|
|
75
75
|
xMint,
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
|
-
convertExamples(examples, example, schemaArray) {
|
|
78
|
+
convertExamples(examples, example, schemaArray, location) {
|
|
79
79
|
if (examples && Object.values(examples).some(({ value }) => value !== undefined)) {
|
|
80
80
|
return Object.fromEntries(Object.entries(examples)
|
|
81
81
|
.filter(([_, { value }]) => value !== undefined)
|
|
@@ -91,7 +91,7 @@ export class BaseOpenApiToEndpointConverter extends BaseConverter {
|
|
|
91
91
|
if (example !== undefined) {
|
|
92
92
|
return { example: { value: example } };
|
|
93
93
|
}
|
|
94
|
-
return { example: { value: generateExampleFromSchema(schemaArray[0]) } };
|
|
94
|
+
return { example: { value: generateExampleFromSchema(schemaArray[0], 0, location) } };
|
|
95
95
|
}
|
|
96
96
|
convertCodeSamples(debugPath, operation) {
|
|
97
97
|
let key;
|
|
@@ -177,7 +177,7 @@ export class OpenApiToEndpointConverter extends BaseOpenApiToEndpointConverter {
|
|
|
177
177
|
contentType,
|
|
178
178
|
safeParse: this.safeParse,
|
|
179
179
|
});
|
|
180
|
-
const examples = this.convertExamples(mediaObject.examples, mediaObject.example, schemaArray);
|
|
180
|
+
const examples = this.convertExamples(mediaObject.examples, mediaObject.example, schemaArray, location);
|
|
181
181
|
return [contentType, { schemaArray, examples, description }];
|
|
182
182
|
});
|
|
183
183
|
return Object.fromEntries(newEntries);
|
|
@@ -263,7 +263,7 @@ export class OpenApiToIncrementalEndpointConverter extends BaseOpenApiToEndpoint
|
|
|
263
263
|
contentType,
|
|
264
264
|
safeParse: this.safeParse,
|
|
265
265
|
});
|
|
266
|
-
const examples = this.convertExamples(dereferencedMediaObject === null || dereferencedMediaObject === void 0 ? void 0 : dereferencedMediaObject.examples, dereferencedMediaObject === null || dereferencedMediaObject === void 0 ? void 0 : dereferencedMediaObject.example, schemaArray);
|
|
266
|
+
const examples = this.convertExamples(dereferencedMediaObject === null || dereferencedMediaObject === void 0 ? void 0 : dereferencedMediaObject.examples, dereferencedMediaObject === null || dereferencedMediaObject === void 0 ? void 0 : dereferencedMediaObject.example, schemaArray, location);
|
|
267
267
|
return [contentType, { schemaArray: incrementalSchemaArray, examples, description }];
|
|
268
268
|
});
|
|
269
269
|
return Object.fromEntries(newEntries);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { DataSchema, DataSchemaArray } from '../index.js';
|
|
2
2
|
export declare const isDataSchemaArray: (schemaArray: unknown) => schemaArray is DataSchemaArray;
|
|
3
|
-
export declare const generateExampleFromSchema: (schema: DataSchema, depth?: number) => unknown;
|
|
3
|
+
export declare const generateExampleFromSchema: (schema: DataSchema, depth?: number, location?: "request" | "response") => unknown;
|
|
@@ -32,7 +32,24 @@ const filterXMint = (schema) => {
|
|
|
32
32
|
}
|
|
33
33
|
return schema;
|
|
34
34
|
};
|
|
35
|
-
|
|
35
|
+
const shouldOmitOptionalObjectExample = (schema, value) => {
|
|
36
|
+
var _a;
|
|
37
|
+
if (schema.type !== 'object' || schema.required === true || schema.minProperties === undefined) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
if (schema.example !== undefined ||
|
|
41
|
+
((_a = schema.examples) === null || _a === void 0 ? void 0 : _a[0]) !== undefined ||
|
|
42
|
+
schema.default !== undefined ||
|
|
43
|
+
('const' in schema && schema.const !== undefined) ||
|
|
44
|
+
('enum' in schema && Array.isArray(schema.enum) && schema.enum.length === 1)) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
return Object.keys(value).length < schema.minProperties;
|
|
51
|
+
};
|
|
52
|
+
export const generateExampleFromSchema = (schema, depth = 0, location) => {
|
|
36
53
|
var _a;
|
|
37
54
|
if (schema.example !== undefined) {
|
|
38
55
|
return schema.example;
|
|
@@ -69,17 +86,20 @@ export const generateExampleFromSchema = (schema, depth = 0) => {
|
|
|
69
86
|
const entries = Object.entries(schemaForExampleGeneration.properties)
|
|
70
87
|
// generate examples for all properties until depth reached - then only required properties
|
|
71
88
|
.filter(([_, [{ required }]]) => depth < MAX_DEPTH || required)
|
|
72
|
-
.
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
89
|
+
.flatMap(([propName, [subschema]]) => {
|
|
90
|
+
const value = generateExampleFromSchema(subschema, depth + 1, location);
|
|
91
|
+
if (location === 'request' && shouldOmitOptionalObjectExample(subschema, value)) {
|
|
92
|
+
return [];
|
|
93
|
+
}
|
|
94
|
+
return [[propName, value]];
|
|
95
|
+
});
|
|
76
96
|
return Object.fromEntries(entries);
|
|
77
97
|
case 'array':
|
|
78
98
|
return depth < MAX_DEPTH
|
|
79
99
|
? [
|
|
80
100
|
generateExampleFromSchema(schemaForExampleGeneration.items[0],
|
|
81
101
|
// prevent the weird [{}] example value by counting array<object> as one level
|
|
82
|
-
schemaForExampleGeneration.items[0].type === 'object' ? depth : depth + 1),
|
|
102
|
+
schemaForExampleGeneration.items[0].type === 'object' ? depth : depth + 1, location),
|
|
83
103
|
]
|
|
84
104
|
: [];
|
|
85
105
|
}
|