Bug Report Checklist
Description
When generating TypeScript Angular code for an OpenAPI schema that contains a map property with an array of inline enums (e.g., additionalProperties with type: array of enum), the generated code produces an invalid type reference InnerEnum instead of the correct qualified enum name.
openapi-generator version
Version 7.10 can compile (but enum is not present), versions 7.11 - 7.19 generate invalid models.
OpenAPI declaration file content or url
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate \
-i https://gist.github.com/saxicek/48d09e5335a266cf316af4924237626e/raw/0b68148756a57a8bbaad4c60634a2e48dbdb4231/inner_enum.yaml \
-g typescript-angular \
-o ./typescript-angular
Steps to reproduce
Generate using:
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate \
-i https://gist.github.com/saxicek/48d09e5335a266cf316af4924237626e/raw/0b68148756a57a8bbaad4c60634a2e48dbdb4231/inner_enum.yaml \
-g typescript-angular \
-o ./typescript-angular
Actual output for status.ts - notice the Array<InnerEnum>:
export interface Status {
options?: { [key: string]: Array<InnerEnum>; };
}
export namespace Status {
export const OptionsEnum = {
Ab01: 'AB01',
Ab02: 'AB02',
Ab03: 'AB03'
} as const;
export type OptionsEnum = typeof OptionsEnum[keyof typeof OptionsEnum];
}
The options property references InnerEnum which is never defined, causing TypeScript compilation errors.
Expected output:
export interface Status {
options?: { [key: string]: Array<Status.OptionsEnum>; };
}
export namespace Status {
export const OptionsEnum = {
Ab01: 'AB01',
Ab02: 'AB02',
Ab03: 'AB03'
} as const;
export type OptionsEnum = typeof OptionsEnum[keyof typeof OptionsEnum];
}
Related issues/PRs
#20877 - but that is not mentioning typescript-angular.
Suggest a fix
In DefaultCodegen.updateDataTypeWithEnumForMap(), the datatypeWithEnum is set using toEnumName(baseItem) which derives the enum name from the inner item's name ("inner" from additionalProperties), producing InnerEnum. However, the actual enum generated by templates uses property.enumName (e.g., OptionsEnum), causing a mismatch.
Bug Report Checklist
Description
When generating TypeScript Angular code for an OpenAPI schema that contains a map property with an array of inline enums (e.g.,
additionalPropertieswithtype: arrayofenum), the generated code produces an invalid type referenceInnerEnuminstead of the correct qualified enum name.openapi-generator version
Version 7.10 can compile (but enum is not present), versions 7.11 - 7.19 generate invalid models.
OpenAPI declaration file content or url
Steps to reproduce
Generate using:
Actual output for
status.ts- notice theArray<InnerEnum>:The
optionsproperty referencesInnerEnumwhich is never defined, causing TypeScript compilation errors.Expected output:
Related issues/PRs
#20877 - but that is not mentioning typescript-angular.
Suggest a fix
In
DefaultCodegen.updateDataTypeWithEnumForMap(), thedatatypeWithEnumis set usingtoEnumName(baseItem)which derives the enum name from the inner item's name ("inner" from additionalProperties), producingInnerEnum. However, the actual enum generated by templates usesproperty.enumName(e.g.,OptionsEnum), causing a mismatch.