hey-api-builders
Version:
A custom plugin for @hey-api/openapi-ts that generates mock data builders with a lightweight custom runtime, Zod integration, or static mock generation.
43 lines • 1.32 kB
TypeScript
import type { Schema } from '../types';
export interface MockOptions {
useDefault?: boolean;
useExamples?: boolean;
alwaysIncludeOptionals?: boolean;
optionalsProbability?: number | false;
omitNulls?: boolean;
requiredOnly?: boolean;
}
/**
* Custom mock data generator for JSON schemas
* This is a lightweight alternative to json-schema-faker
*/
export declare class MockGenerator {
private options;
private seenRefs;
constructor(options?: MockOptions);
/**
* Generate mock data from schema
*/
generate(schema: Schema): unknown;
private generateValue;
private generateByType;
private generateNumber;
private generateString;
private generateStringByFormat;
private generateStringForPattern;
private generateArray;
private generateObject;
private generateAllOf;
private shouldIncludeOptional;
private shouldIncludeNull;
}
/**
* Generates mock data using custom mock generator
* @param schema - JSON Schema
* @param options - Generation options
* @returns Generated mock data
*/
export declare function generateMock<T = unknown>(schema: unknown, options?: MockOptions): T;
export type { BuilderOptions } from '../types';
export type { Schema as BuilderSchema } from '../types';
//# sourceMappingURL=mock-runtime.d.ts.map