openapi-ts-mock-generator
Version:
typescript mock data generator based openapi
53 lines (50 loc) • 1.49 kB
TypeScript
import { OpenAPIV3_1 } from 'openapi-types';
type Options = {
path: string;
arrayMinLength?: number;
arrayMaxLength?: number;
isStatic: boolean;
includeCodes?: number[];
baseDir?: string;
specialPath?: string;
handlerUrl: string;
fakerLocale: string;
generateTarget: string;
clear?: boolean;
};
type SchemaOutputType = string | number | boolean | null | undefined | Date;
type NestedSchemaOutputType<T> = {
[K in keyof T]: T[K] extends object ? NestedSchemaOutputType<T[K]> : T[K];
} | SchemaOutputType | {};
type ParseSchemaType = NestedSchemaOutputType<string>;
declare enum HttpMethods {
GET = "get",
PUT = "put",
POST = "post",
DELETE = "delete",
OPTIONS = "options",
HEAD = "head",
PATCH = "patch",
TRACE = "trace"
}
type ResponseSchemaType = {
type: "anyOf" | "oneOf" | "array";
value: OpenAPIV3_1.SchemaObject;
} | {
type: "ref";
value: OpenAPIV3_1.ReferenceObject;
} | undefined;
type PathNormalizedType = {
pathname: string;
operationId: string;
summary: string;
method: HttpMethods;
responses: {
statusCode: number;
description: string;
schema: ResponseSchemaType;
}[];
tags: string[];
};
declare const isNotNullish: <TValue>(value: TValue | null | undefined) => value is TValue;
export { HttpMethods, type Options, type ParseSchemaType, type PathNormalizedType, type ResponseSchemaType, type SchemaOutputType, isNotNullish };