@mintlify/validation
Version:
Validates mint.json files
91 lines (90 loc) • 2.37 kB
JavaScript
import { type } from 'arktype';
export class EndpointLocation {
constructor(document, path) {
var _a;
this.document = document;
this.endpointPath = path;
this.path = ((_a = document.webhooks) === null || _a === void 0 ? void 0 : _a[path]) ? 'webhooks' : 'paths';
this.type = this.path.slice(0, -1);
}
getEndpointPaths() {
return this.document[this.path];
}
getEndpoint() {
var _a;
return (_a = this.document[this.path]) === null || _a === void 0 ? void 0 : _a[this.endpointPath];
}
}
// Request types
export const httpMethods = [
'get',
'put',
'post',
'delete',
'options',
'head',
'patch',
'trace',
];
// Schema types
export const typeList = [
'boolean',
'string',
'number',
'integer',
'object',
'array',
'enum<string>',
'enum<number>',
'enum<integer>',
'file',
'null',
'any',
];
// arktype types for validation
const IconType = type("'brands' | 'duotone' | 'light' | 'regular' | 'sharp-duotone-solid' | 'sharp-light' | 'sharp-regular' | 'sharp-solid' | 'sharp-thin' | 'solid' | 'thin'");
const ApiPlaygroundDisplayType = type("'interactive' | 'simple' | 'none'");
const PageMetaTagsType = type({
'+': 'delete',
'href?': 'string',
'title?': 'string',
'og:title?': 'string',
'sidebarTitle?': 'string',
'description?': 'string',
'api?': 'string',
'openapi?': 'string',
'asyncapi?': 'string',
'contentType?': 'string',
'authMethod?': 'string',
'auth?': 'string',
'version?': 'string',
'mode?': 'string',
'hideFooterPagination?': 'boolean',
'authors?': 'unknown',
'lastUpdatedDate?': 'string',
'createdDate?': 'string',
'openapi-schema?': 'string',
'icon?': 'string',
'iconType?': IconType,
'tag?': 'string',
'url?': 'string',
'hideApiMarker?': 'boolean',
'noindex?': 'boolean',
'isPublic?': 'boolean',
'public?': 'boolean',
'playground?': ApiPlaygroundDisplayType,
'keywords?': 'string[]',
});
export const XMcpType = type({
'+': 'delete',
'enabled?': 'boolean',
'name?': 'string',
'description?': 'string',
});
export const XMintType = type({
'+': 'delete',
'metadata?': PageMetaTagsType,
'content?': 'string',
'href?': 'string',
'mcp?': XMcpType,
});