openapi-tsk
Version:
openapi tool to use with NodeTskeleton template project
96 lines (95 loc) • 2.45 kB
TypeScript
import { IApiDocGenerator, ApiDocRouteType, SecurityScheme, UrlParamDescriber } from "../resources/IApiDocGenerator";
import { PropFormatEnum, PropTypeEnum } from "../resources/types";
type SchemaType = {
type?: PropTypeEnum;
} | {
$ref?: string;
} | {
type?: PropTypeEnum.OBJECT | PropTypeEnum.ARRAY;
items?: {
$ref: string;
};
};
type RequestBodyType = {
description?: string;
required?: boolean;
content: Record<string, {
schema: {
$ref: string;
};
}>;
};
type OpenApiType = {
openapi: string;
info: {
title: string;
version: string;
description: string;
contact: {
name: string;
url: string;
email: string;
};
license: {
name: string;
};
};
servers: {
url: string;
description: string;
}[];
paths: Record<string, Record<string, {
tags?: string[];
description: string;
responses: Record<string, {
description?: string;
content: Record<string, {
schema: SchemaType;
}>;
}>;
requestBody: RequestBodyType;
parameters: UrlParamDescriber[];
security: Record<string, any[]>[];
}>>;
components: {
schemas: Record<string, {
type: string;
properties: {
type: PropTypeEnum;
format: PropFormatEnum;
};
}>;
securitySchemes?: Record<string, SecurityScheme>;
};
};
export declare class ApiDocGenerator implements IApiDocGenerator {
#private;
readonly env: string;
apiDoc: OpenApiType;
constructor(env: string, info: {
title: string;
version: string;
description: string;
contact: {
name: string;
url: string;
email: string;
};
license: {
name: string;
};
});
private setSchemas;
private setSchemasSecurity;
private buildParameters;
private buildSchema;
private buildRequestBody;
private filterNonElegibleTags;
private getTagFromPath;
setApiRootPath(path: string): void;
saveApiDoc(dirName: string, filePath: string): this;
createRouteDoc(route: ApiDocRouteType): void;
setServerUrl(url: string, description: "Local server"): void;
finish(): void;
}
export {};