openapi-tsk
Version:
openapi tool to use with NodeTskeleton template project
79 lines (78 loc) • 3.04 kB
TypeScript
import { SecurityScheme, SecuritySchemeType, UrlParamDescriber } from "./IApiDocGenerator";
import { ClassProperty, PropFormatEnum, PropTypeEnum, ZodObject } from "./types";
import "reflect-metadata";
type Primitive = PropTypeEnum.STRING | PropTypeEnum.NUMBER | PropTypeEnum.BOOLEAN | PropTypeEnum.NULL | PropTypeEnum.UNDEFINED;
type PrimitiveDefinition = {
primitive: Primitive;
format?: PropFormatEnum;
};
export declare class TypeDescriber<T> {
readonly type: PropTypeEnum.OBJECT | PropTypeEnum.ARRAY | PropTypeEnum.PRIMITIVE;
readonly properties: Record<keyof T, ClassProperty | TypeDescriber<any> | {
$ref: string;
}> | PrimitiveDefinition;
readonly schema: {
name: string;
type: PropTypeEnum;
required?: string[];
properties: Record<string, ClassProperty> | {
type: PropTypeEnum;
};
};
static readonly referenceSchemas: Record<string, {
type: PropTypeEnum;
properties: Record<string, ClassProperty> | {
$ref: string;
};
required?: string[];
}>;
constructor(obj: {
name: string;
type: PropTypeEnum.OBJECT | PropTypeEnum.ARRAY | PropTypeEnum.PRIMITIVE;
props: Record<keyof T, ClassProperty | TypeDescriber<any> | {
$ref: string;
}> | PrimitiveDefinition;
});
static describePrimitive(primitive: Primitive, format?: PropFormatEnum): PrimitiveDefinition;
static describeUrlParam(param: UrlParamDescriber): UrlParamDescriber;
static describeProps<T>(input: Record<keyof T, ClassProperty | PropTypeEnum | {
$ref: string;
}>): Record<keyof T, ClassProperty | TypeDescriber<any>>;
static describeReference<T>(name: string, input: Record<keyof T, any>): {
$ref: string;
};
static describeArrayReference<T>(name: string, input: Record<keyof T, any>): {
$ref: string;
};
static describeZodObject(name: string, zodObject: ZodObject<any>, type?: PropTypeEnum.OBJECT | PropTypeEnum.ARRAY): TypeDescriber<any>;
}
export declare class RefTypeDescriber {
readonly type: PropTypeEnum.OBJECT | PropTypeEnum.ARRAY;
readonly schema: {
name: string;
definition: {
$ref?: string;
} | {
type: PropTypeEnum.ARRAY;
items?: {
$ref: string;
};
};
};
constructor(obj: {
type: PropTypeEnum.OBJECT | PropTypeEnum.ARRAY;
name: string;
});
}
export declare class SecuritySchemesDescriber {
static readonly HTTP = "http";
static readonly API_KEY = "apiKey";
static readonly OAUTH2 = "oauth2";
static readonly OPEN_ID_CONNECT = "openIdConnect";
static readonly MUTUAL_TLS = "mutualTLS";
[key: string]: SecurityScheme;
constructor(key: SecuritySchemeType, securitySchemes: SecurityScheme);
static defaultHttpBearer(): SecurityScheme;
static defaultHttpApiKey(apiKeyName: string, into: "query" | "header" | "cookie"): SecurityScheme;
}
export {};