Files
openapi-clean-arch-gen/src/types/openapi.types.ts
didavila 463626da0c feat: add .spec.ts generation for models, mappers, repositories and use-cases
Add 4 new Mustache templates for generating unit test specs:
- model-entity.spec.mustache: tests instantiation, property setting, mock builder
- mapper.spec.mustache: tests per-property DTO→Entity mapping, instanceof, all fields
- api.repository.impl.spec.mustache: tests HTTP method, response mapping, error propagation
- api.use-cases.impl.spec.mustache: tests repository delegation, observable forwarding

Generator changes:
- Add uppercaseHttpMethod to TagOperation for spec HTTP assertions
- Add testValue to TagOperationParam for auto-generated test arguments
- Add resolveTestParamValue utility for primitive/complex type test literals
- Add specs counter to GeneratedCount and GenerationReport
- Wire 4 new renderTemplate calls in schema and tag loops
- Update report generator to count .spec.ts files

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-26 10:52:58 +01:00

125 lines
2.7 KiB
TypeScript

/**
* Summary of a single endpoint for display on the interactive selection screen.
*/
export interface OperationSummary {
nickname: string;
method: string;
path: string;
summary: string;
}
/**
* Tag with its summarised endpoints, used on the interactive selection screen.
*/
export interface TagSummary {
tag: string;
operations: OperationSummary[];
}
/**
* Selection filter map: tag → array of selected operation nicknames.
*/
export type SelectionFilter = Record<string, string[]>;
/**
* Simplified representation of an OpenAPI component schema.
* Used to generate domain models (entities) and mappers.
*/
export interface OpenApiSchema {
properties?: Record<
string,
{
type?: string;
format?: string;
description?: string;
example?: unknown;
enum?: unknown[];
$ref?: string;
items?: { $ref?: string; type?: string };
}
>;
required?: string[];
description?: string;
}
/**
* Representation of an OpenAPI operation (GET, POST, etc.) within a path.
* Contains the information needed to generate repositories and use cases.
*/
export interface OpenApiOperation {
tags?: string[];
operationId?: string;
summary?: string;
description?: string;
parameters?: Array<{
name: string;
in: string;
required: boolean;
description?: string;
schema?: { type?: string };
}>;
requestBody?: {
description?: string;
content?: Record<
string,
{
schema?: {
$ref?: string;
type?: string;
};
}
>;
};
responses?: Record<
string,
{
content?: Record<
string,
{
schema?: {
$ref?: string;
type?: string;
items?: { $ref?: string };
};
}
>;
}
>;
}
/**
* A single parameter of a normalised API operation, ready for Mustache template consumption.
*/
export interface TagOperationParam {
paramName: string;
dataType: string;
description: string;
required: boolean;
'-last': boolean;
testValue?: string;
}
/**
* Normalised operation ready to be consumed by Mustache templates.
* Each instance represents an endpoint grouped under an API tag.
*/
export interface TagOperation {
nickname: string;
summary: string;
notes: string;
httpMethod: string;
uppercaseHttpMethod: string;
path: string;
allParams: TagOperationParam[];
hasQueryParams: boolean;
queryParams: unknown[];
hasBodyParam: boolean;
bodyParam: string;
returnType: string | boolean;
returnBaseType: string | boolean;
returnTypeVarName: string | boolean;
returnBaseTypeVarName: string | boolean;
isListContainer: boolean;
vendorExtensions: Record<string, unknown>;
}