OpenAPITools / OpenAPITools/openapi-generator
[BUG] [typescript-angular] confusing warning "model name matches existing language type"
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
Description
Consider the following openapi json:
{
"openapi": "3.0.3",
"info": {
"title": "Api Documentation",
"version": "1.0"
},
"paths": {
"/test": {
"get": {
"parameters": [
{
"name": "date",
"in": "query",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK"
}
}
}
}
}
}
The parameter name is date. When a typescript-angular generation is done, the following warning appears on the command line:
Date (model name matches existing language type) cannot be used as a model name. Renamed to ModelDate
At the same time, the following typescript service is generated (fragment only):
public testGet(date?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext}): Observable<any>;
public testGet(date?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext}): Observable<HttpResponse<any>>;
public testGet(date?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext}): Observable<HttpEvent<any>>;
public testGet(date?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: undefined, context?: HttpContext}): Observable<any> {
The string ModelDate does not appear anywhere in the generated code.
If the name of the parameter is changed to Date, the same thing happens: warning appears, function parameter name remains date and the string ModelDate does not appear in the code.
If the name of the parameter is changed to datex, the warning disappears.
If the parameter is renamed to int or typeof, the warning again does not appear, however the parameter name in the testGet method changes to _int and _typeof respectively.
It is not a problem, it just annoys me (I have just cleaned up a dozen or so warnings, all of which were useful in pointing me to create a better task configuration, but I cannot get this one to go away - changing the name of the parameter is not an option).
Expected behaviour
The warning does not appear when no renaming happens in the generated code.
openapi-generator version
6.1.0
Generation Details
The gradle plugin is used, with the following configuration:
task('gen_test', type: GenerateTask) {
generatorName = "typescript-angular"
inputSpec = "$rootDir/openapi/test.json"
outputDir = "$buildDir/generated/openapi-test-lib-client"
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Run the Gradle GenerateTask for generatorName "typescript-angular" with the issue's openapi/test.json input and compare the warning with the generated service. Trace the generation path that reports the model-name warning; done means the warning is absent when the generated parameter remains unchanged, while genuine renaming warnings still appear.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, openapi, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100