openapi-generator
openapi-generator copied to clipboard
[BUG][TypeScript] angular modelSuffix nested model bad import
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)?
- [x] 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?
- [ ] [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
While you generate api with typescript-angular and you will use modelSuffix as additional property, models are generated correctly, but if it is nested model for another model, the import is generated wrongly. Suffix is generated twice at the end of path from.
Example: modelSuffix=example
GeneratedCode: import { MunicipalityRestDtoExample } from './municipalityRestDtoExampleExample';
openapi-generator version
openapi-generator-cli version 7.11.0
OpenAPI declaration file content or url
{
"openapi": "3.0.1",
"info": {
"title": "API",
"description": "",
"version": "0.0.4-SNAPSHOT"
},
"paths": {},
"components": {
"schemas": {
"MunicipalityResponseRestDto": {
"type": "object",
"properties": {
"municipalities": { "type": "array", "items": { "$ref": "#/components/schemas/MunicipalityRestDto" } }
}
},
"MunicipalityRestDto": {
"type": "object",
"properties": {
"name": { "type": "string", "description": "Municipality name." }
}
}
}
}
}
Generation Details
openapi-generator-cli generate -i path/to/api.json -g typescript-angular --additional-properties=modelSuffix=example -o path/to/output/api
Steps to reproduce
- Create JSON file from spec above
- Generate api with command in generation details section