openapi-generator
openapi-generator copied to clipboard
[BUG] [typescript-angular] confusing warning "model name matches existing language type"
Bug Report Checklist
- [x] Have you provided a full/minimal spec to reproduce the issue?
- [x] Have you validated the input using an OpenAPI validator (example)?
- [ ] Have you tested with the latest master to confirm the issue still exists?
- [x] Have you searched for related issues/PRs?
- [x] 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"
}