-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
[typescript-angular] Fix inner enum reference in multi-map property type #22748
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
b112c18
decf2cf
94499fa
8f72be1
213ee3f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -383,6 +383,7 @@ protected void addAdditionPropertiesToCodeGenModel(CodegenModel codegenModel, Sc | |
|
|
||
| @Override | ||
| public ModelsMap postProcessModels(ModelsMap objs) { | ||
| // postProcessModelsEnum applies inner enum fixes via the parent class override | ||
| List<ModelMap> models = postProcessModelsEnum(objs).getModels(); | ||
|
|
||
| // process enum and custom properties in models | ||
|
|
@@ -800,7 +801,8 @@ private ExtendedCodegenModel processCodeGenModel(ExtendedCodegenModel cm) { | |
| for (CodegenProperty cpVar : cm.allVars) { | ||
| ExtendedCodegenProperty var = (ExtendedCodegenProperty) cpVar; | ||
|
|
||
| if (Boolean.TRUE.equals(var.isEnum)) { | ||
| // Handle both direct enum properties and inner enums (maps/arrays of enums) | ||
| if (Boolean.TRUE.equals(var.isEnum) || Boolean.TRUE.equals(var.isInnerEnum)) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Inner enum names can be double-prefixed for child properties when a model has a parent: processCodegenProperty already prefixes isInnerEnum, and the new inheritance loop prefixes isInnerEnum again on cm.allVars, which reuses the same property objects for child vars. Prompt for AI agents
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The concern about double-prefixing is theoretical but not an actual bug in practice. My investigation shows: Why there's no double-prefix bug:
Therefore, modifying properties in
saxicek marked this conversation as resolved.
|
||
| var.datatypeWithEnum = var.datatypeWithEnum | ||
| .replace(var.enumName, cm.classname + var.enumName); | ||
| } | ||
|
|
@@ -845,7 +847,9 @@ private ExtendedCodegenModel processCodeGenModel(ExtendedCodegenModel cm) { | |
|
|
||
| private boolean processCodegenProperty(ExtendedCodegenProperty var, String parentClassName, Object xEntityId) { | ||
| // name enum with model name, e.g. StatusEnum => PetStatusEnum | ||
| if (Boolean.TRUE.equals(var.isEnum)) { | ||
| // This applies to both direct enum properties (isEnum) and properties containing | ||
| // inner enums (isInnerEnum) like maps or arrays of enums. | ||
| if (Boolean.TRUE.equals(var.isEnum) || Boolean.TRUE.equals(var.isInnerEnum)) { | ||
| // behaviour for enum names is specific for Typescript Fetch, not using namespaces | ||
| var.datatypeWithEnum = var.datatypeWithEnum.replace(var.enumName, parentClassName + var.enumName); | ||
|
|
||
|
|
@@ -1525,11 +1529,11 @@ public class ExtendedCodegenModel extends CodegenModel { | |
| public Set<CodegenProperty> oneOfPrimitives = new HashSet<>(); | ||
| @Getter @Setter | ||
| public CodegenDiscriminator.MappedModel selfReferencingDiscriminatorMapping; | ||
|
|
||
| public boolean isEntity; // Is a model containing an "id" property marked as isUniqueId | ||
| public String returnPassthrough; | ||
| public boolean hasReturnPassthroughVoid; | ||
|
|
||
| public boolean hasSelfReferencingDiscriminatorMapping(){ | ||
| return selfReferencingDiscriminatorMapping != null; | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.