UNPKG

@mintlify/validation

Version:

Validates mint.json files

200 lines (199 loc) 5.87 kB
import { OpenAPIV3, OpenAPIV3_1 } from 'openapi-types'; import { XMcp, XMint, HttpMethod, EndpointType } from '../../types/endpoint.js'; export type UUID = string; export type HashId = string; export type RefUuidMap = Record<string, UUID>; export type UUIDObjectHashMap = Record<UUID, HashId>; export type HashedNodeMap = Record<HashId, GraphNode>; export type GraphNode = SchemaOrRef | ResponseOrRef | HeaderOrRef | ParameterOrRef | Media | ExampleOrRef | RequestBodyOrRef | SecuritySchemeOrRef | ServerObject | PathOrRef | Operation | SecurityRequirement | Document; export type SchemaObject = OpenAPIV3.SchemaObject | OpenAPIV3_1.SchemaObject; export type ArraySchemaObject = OpenAPIV3_1.ArraySchemaObject; export type NonArraySchemaObject = OpenAPIV3_1.NonArraySchemaObject; export type RefObject = OpenAPIV3.ReferenceObject | OpenAPIV3_1.ReferenceObject; export type SchemaOrRefObject = SchemaObject | RefObject; export type SchemaOrRef = (SchemaOrRefObject & { items?: UUID; properties?: { [name: string]: UUID; }; additionalProperties?: boolean | UUID; allOf?: UUID[]; anyOf?: UUID[]; oneOf?: UUID[]; not?: UUID; } & { $ref?: never; }) | (RefObject & { $ref: UUID; } & { items?: never; properties?: never; additionalProperties?: never; allOf?: never; anyOf?: never; oneOf?: never; not?: never; }) | HashId; export type ResponseObject = OpenAPIV3.ResponseObject | OpenAPIV3_1.ResponseObject; export type ResponseOrRefObject = ResponseObject | RefObject; export type ResponseOrRef = (ResponseObject & { headers?: { [header: string]: UUID; }; content?: { [contentType: string]: UUID; }; links?: { [link: string]: UUID; }; } & { $ref?: never; }) | (RefObject & { $ref: UUID; } & { headers?: never; content?: never; links?: never; }); export type HeaderObject = OpenAPIV3.HeaderObject | OpenAPIV3_1.HeaderObject; export type HeaderOrRefObject = HeaderObject | RefObject; export type HeaderOrRef = (HeaderObject & { schema?: UUID; examples?: { [name: string]: UUID; }; content?: { [contentType: string]: UUID; }; } & { $ref?: never; }) | (RefObject & { $ref: UUID; } & { schema?: never; examples?: never; content?: never; }); export type ParameterObject = OpenAPIV3.ParameterObject | OpenAPIV3_1.ParameterObject; export type ParameterOrRefObject = ParameterObject | RefObject; export type ParameterOrRef = (ParameterObject & { schema?: UUID; examples?: { [name: string]: UUID; }; content?: { [contentType: string]: UUID; }; } & { $ref?: never; }) | (RefObject & { $ref: UUID; } & { schema?: never; examples?: never; content?: never; }); export type MediaObject = OpenAPIV3.MediaTypeObject | OpenAPIV3_1.MediaTypeObject; export type Media = MediaObject & { schema?: UUID; examples?: { [name: string]: UUID; }; encoding?: { [encoding: string]: UUID; }; }; export type ExampleObject = OpenAPIV3.ExampleObject | OpenAPIV3_1.ExampleObject; export type ExampleOrRefObject = ExampleObject | RefObject; export type ExampleOrRef = (ExampleObject & { $ref?: never; }) | (RefObject & { $ref: UUID; } & { value?: never; }); export type RequestBodyObject = OpenAPIV3.RequestBodyObject | OpenAPIV3_1.RequestBodyObject; export type RequestBodyOrRefObject = RequestBodyObject | RefObject; export type RequestBodyOrRef = (RequestBodyObject & { content?: { [contentType: string]: UUID; }; } & { $ref?: never; }) | (RefObject & { $ref: UUID; } & { content?: never; }); export type SecuritySchemeObject = OpenAPIV3.SecuritySchemeObject | OpenAPIV3_1.SecuritySchemeObject; export type SecuritySchemeOrRefObject = SecuritySchemeObject | RefObject; export type SecuritySchemeOrRef = (SecuritySchemeObject & { $ref?: never; }) | (RefObject & { $ref: UUID; }); export type ServerObject = OpenAPIV3.ServerObject | OpenAPIV3_1.ServerObject; export type PathObject = OpenAPIV3.PathItemObject | OpenAPIV3_1.PathItemObject; export type PathObjectOrRef = PathObject | RefObject; export type PathOrRef = (PathObject & { path: string; parameters?: UUID[]; } & { [method in OpenAPIV3.HttpMethods]: UUID; } & { $ref?: never; }) | (RefObject & { path: string; $ref: UUID; } & { parameters?: never; } & { [method in OpenAPIV3.HttpMethods]: never; }); export type OperationObject = OpenAPIV3.OperationObject | OpenAPIV3_1.OperationObject; export type OperationExtensions = { 'x-mint'?: XMint; 'x-mcp'?: XMcp; 'x-excluded'?: boolean; 'x-hidden'?: boolean; 'x-codeSamples'?: string[]; 'x-code-samples'?: string[]; }; export type Operation = Omit<OperationObject, 'servers' | 'security'> & { method: HttpMethod; type: EndpointType; parameters?: UUID[]; requestBody?: UUID; responses?: { [status: string]: UUID; }; callbacks?: { [callback: string]: UUID; }; security?: UUID[]; servers?: UUID[]; } & OperationExtensions; export type SecurityRequirementObject = OpenAPIV3.SecurityRequirementObject | OpenAPIV3_1.SecurityRequirementObject; export type SecurityRequirement = { [name: string]: { $ref?: UUID; scopes?: string[]; }; }; export type DocumentObject = OpenAPIV3.Document | OpenAPIV3_1.Document; export type Document = Omit<DocumentObject, 'servers' | 'paths' | 'webhooks' | 'security'> & { servers: UUID[]; paths: UUID[]; webhooks: UUID[]; security: UUID[]; }; export type SchemaGraphData = { filename: string; originalFileLocation?: string; documentId: UUID; spec: { uuidObjectHashMap: UUIDObjectHashMap; hashedNodeMap: HashedNodeMap; refUuidMap: RefUuidMap; }; };