-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
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?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Hi, it seems there is case collision issue with schema names in typescript generator.
When schema names conflict due to case differences, the generated model file names are suffixed with index,
but the model import and export statements don’t reflect those file names, causing broken references.
I first encountered this with typescript-axios generator, but the issue is reproducible with typescript generator.
I think I found related change #19715, and following fix #19913 although it is not directly related to typescript.
openapi-generator version
v7.9.0 or higher
OpenAPI declaration file content or url
{
"openapi": "3.0.1",
"info": {},
"paths": {},
"components": {
"schemas": {
"Response": {
"required": ["upper", "lower"],
"type": "object",
"properties": {
"upper": {
"$ref": "#/components/schemas/ModelA"
},
"lower": {
"$ref": "#/components/schemas/Modela"
}
}
},
"ModelA": {
"type": "string",
"enum": ["A", "B"]
},
"Modela": {
"type": "string",
"enum": ["A", "B"]
}
}
}
}
openapitools.json
{
"generator-cli": {
"version": "7.12.0",
"generators": {
"typescript": {
"inputSpec": "./spec.json",
"output": "./generated",
"generatorName": "typescript-axios",
"additionalProperties": {
"withSeparateModelsAndApi": true,
"apiPackage": "apis",
"modelPackage": "models"
}
}
}
}
}
Generation Details
The schema Modela creates modela0.ts, but the model is not referenced with index-suffixed file name.
// response.ts
import type { ModelA } from './model-a';
import type { Modela } from './modela';
export interface Response {
'upper': ModelA;
'lower': Modela;
}// index.ts
export * from './model-a';
export * from './modela';
export * from './response';Steps to reproduce
java -jar "openapi-generator-cli.jar" generate --input-spec ./spec.json --output ./generated --generator-name typescript-axios --additional-properties withSeparateModelsAndApi=true,apiPackage=apis,modelPackage=models
Related issues/PRs
Suggest a fix
Not sure but changes regarding seenModelFilenames needs to be reverted just like #19913?