All checks were successful
Lint / lint (pull_request) Successful in 31s
Bug 1 - Body as positional argument (api.repository.impl.mustache):
MRepository HTTP methods accept a single RequestOptions object as second
argument. The template was incorrectly passing body as a separate positional
argument (e.g. this.post('/url', body)), causing:
'Type X has no properties in common with type RequestOptions'
Fix: merge body into the options object using ES6 shorthand { body }, and
introduce hasOptions / hasBothParamsAndBody flags to build a single unified
options literal covering all scenarios:
- no options → this.post('/url')
- params only → this.get('/url', { params: { search } })
- body only → this.post('/url', { body })
- params + body → this.post('/url', { params: { search }, body })
Bug 2 - Only 200 responses read (clean-arch.generator.ts):
The generator was hardcoded to read op.responses['200'], silently ignoring
201 Created, 202 Accepted, etc. POST endpoints returning 201 were generated
as Observable<void> instead of their actual return type.
Fix: resolve the first available success code from [200, 201, 202, 203].
New fields added to TagOperation type:
- uppercaseHttpMethod: string
- hasOptions: boolean
- hasBothParamsAndBody: boolean
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
127 lines
2.7 KiB
TypeScript
127 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;
|
|
hasOptions: boolean;
|
|
hasBothParamsAndBody: boolean;
|
|
returnType: string | boolean;
|
|
returnBaseType: string | boolean;
|
|
returnTypeVarName: string | boolean;
|
|
returnBaseTypeVarName: string | boolean;
|
|
isListContainer: boolean;
|
|
vendorExtensions: Record<string, unknown>;
|
|
}
|