-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationenhancementNew feature or requestNew feature or request
Description
Problem
The tool generated mock data based only on TypeScript types, without respecting specific business constraints. For example, a badge: string field was generated without considering the 10-character limit imposed by the future backend.
Solution Implemented
Added a comprehensive JSDoc annotation system to specify constraints directly in TypeScript interfaces. These constraints guide the mock data generation process.
Features
- Constraint Extraction (
constraintExtractor.ts) : Parses JSDoc annotations (@minlength, @maxlength, @pattern, @min, @max, @enum) directly from TypeScript code - Constraint Validation (
constraintValidator.ts) : Validates that generated values respect the defined rules - Guided Generation (
constrainedGenerator.ts) : Automatically generates data that respects constraints - Transparent Integration : Constraints are applied automatically during generation, with no API changes
Supported Constraints
| Annotation | Type | Example |
|---|---|---|
@minLength |
string | @minLength 3 |
@maxLength |
string | @maxLength 10 |
@pattern |
string | @pattern ^[a-z]+$ |
@min |
number | @min 1 |
@max |
number | @max 100 |
@enum |
any | @enum ACTIVE,INACTIVE,PENDING |
Example
// @endpoint
export interface Badge {
/** @maxLength 10 */
label: string;
/** @min 1 @max 5 */
level: number;
/** @enum ACTIVE,INACTIVE,PENDING */
status: string;
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationenhancementNew feature or requestNew feature or request