@trpc/openapi
Version:
121 lines (119 loc) • 5.41 kB
text/typescript
import { OpenAPIV3_1 } from "openapi-types";
//#region rolldown:runtime
declare namespace types_d_exports {
export { ArraySchemaObject, CallbackObject, ComponentsObject, DiscriminatorObject, Document, ExampleObject, ExternalDocumentationObject, HeaderObject, HttpMethods, LinkObject, MediaTypeObject, OperationObject, ParameterBaseObject, ParameterObject, PathItemObject, PathsObject, PrimitiveSchemaType, ReferenceObject, Replace, RequestBodyObject, ResponseObject, ResponsesObject, SchemaLike, SchemaObject, SchemaType, SecuritySchemeObject, XMLObject };
}
type Replace<TTarget, TReplaceWith> = Omit<TTarget, keyof TReplaceWith> & TReplaceWith;
type SchemaType = 'array' | 'boolean' | 'integer' | 'null' | 'number' | 'object' | 'string';
type PrimitiveSchemaType = SchemaType;
type HttpMethods = OpenAPIV3_1.HttpMethods;
type ReferenceObject = OpenAPIV3_1.ReferenceObject;
type ExampleObject = OpenAPIV3_1.ExampleObject;
type DiscriminatorObject = OpenAPIV3_1.DiscriminatorObject;
type ExternalDocumentationObject = OpenAPIV3_1.ExternalDocumentationObject;
type XMLObject = OpenAPIV3_1.XMLObject;
type LinkObject = OpenAPIV3_1.LinkObject;
type SecuritySchemeObject = OpenAPIV3_1.SecuritySchemeObject;
type SchemaObject = Replace<OpenAPIV3_1.BaseSchemaObject, {
$ref?: string;
$defs?: Record<string, SchemaObject>;
$schema?: string;
type?: string | string[];
properties?: Record<string, SchemaObject>;
required?: string[];
items?: SchemaObject | false;
prefixItems?: SchemaObject[];
const?: string | number | boolean | null;
enum?: (string | number | boolean | null)[];
oneOf?: SchemaObject[];
anyOf?: SchemaObject[];
allOf?: SchemaObject[];
not?: SchemaObject;
additionalProperties?: boolean | SchemaObject;
discriminator?: DiscriminatorObject;
externalDocs?: ExternalDocumentationObject;
xml?: XMLObject;
contentMediaType?: string;
exclusiveMinimum?: boolean | number;
exclusiveMaximum?: boolean | number;
}>;
type SchemaLike = SchemaObject;
interface ArraySchemaObject extends SchemaObject {
type: 'array';
items: SchemaObject | false;
}
type MediaTypeObject = Replace<OpenAPIV3_1.MediaTypeObject, {
schema?: SchemaObject | ReferenceObject;
examples?: Record<string, ReferenceObject | ExampleObject>;
}>;
interface ParameterBaseObject extends Replace<OpenAPIV3_1.ParameterBaseObject, {
schema?: SchemaObject | ReferenceObject;
examples?: Record<string, ReferenceObject | ExampleObject>;
content?: Record<string, MediaTypeObject>;
}> {}
interface ParameterObject extends ParameterBaseObject {
name: string;
in: string;
}
type HeaderObject = ParameterBaseObject;
type RequestBodyObject = Replace<OpenAPIV3_1.RequestBodyObject, {
content: Record<string, MediaTypeObject>;
}>;
type ResponseObject = Replace<OpenAPIV3_1.ResponseObject, {
headers?: Record<string, ReferenceObject | HeaderObject>;
content?: Record<string, MediaTypeObject>;
links?: Record<string, ReferenceObject | LinkObject>;
}>;
type ResponsesObject = Record<string, ReferenceObject | ResponseObject>;
type OperationObject<T extends {} = {}> = Replace<OpenAPIV3_1.OperationObject<T>, {
parameters?: (ReferenceObject | ParameterObject)[];
requestBody?: ReferenceObject | RequestBodyObject;
responses?: ResponsesObject;
callbacks?: Record<string, ReferenceObject | CallbackObject>;
}> & T;
type PathItemObject<T extends {} = {}> = Replace<OpenAPIV3_1.PathItemObject<T>, {
parameters?: (ReferenceObject | ParameterObject)[];
}> & { [method in HttpMethods]?: OperationObject<T> };
type PathsObject<T extends {} = {}, TPath extends {} = {}> = Record<string, (PathItemObject<T> & TPath) | undefined>;
type CallbackObject = Record<string, PathItemObject | ReferenceObject>;
type ComponentsObject = Replace<OpenAPIV3_1.ComponentsObject, {
schemas?: Record<string, SchemaObject>;
responses?: Record<string, ReferenceObject | ResponseObject>;
parameters?: Record<string, ReferenceObject | ParameterObject>;
requestBodies?: Record<string, ReferenceObject | RequestBodyObject>;
headers?: Record<string, ReferenceObject | HeaderObject>;
links?: Record<string, ReferenceObject | LinkObject>;
callbacks?: Record<string, ReferenceObject | CallbackObject>;
pathItems?: Record<string, ReferenceObject | PathItemObject>;
}>;
type Document<T extends {} = {}> = Replace<OpenAPIV3_1.Document<T>, {
paths?: PathsObject<T>;
components?: ComponentsObject;
}>;
//# sourceMappingURL=types.d.ts.map
//#endregion
//#region src/generate.d.ts
interface GenerateOptions {
/**
* The name of the exported router symbol.
* @default 'AppRouter'
*/
exportName?: string;
/** Title for the generated OpenAPI `info` object. */
title?: string;
/** Version string for the generated OpenAPI `info` object. */
version?: string;
}
/**
* Analyse the given TypeScript router file using the TypeScript compiler and
* return an OpenAPI 3.1 document describing all query and mutation procedures.
*
* @param routerFilePath - Absolute or relative path to the file that exports
* the AppRouter.
* @param options - Optional generation settings (export name, title, version).
*/
declare function generateOpenAPIDocument(routerFilePath: string, options?: GenerateOptions): Promise<Document>;
//# sourceMappingURL=generate.d.ts.map
//#endregion
export { GenerateOptions, types_d_exports as OpenAPIV3_1, generateOpenAPIDocument };
//# sourceMappingURL=index.d.cts.map