@@ -255,4 +255,40 @@ public void givenMapWithArrayOfEnumsThenCorrectEnumNameIsUsed() throws Exception
255255 }
256256 }
257257
258+ @ Test (description = "Issue #22748 - Inner enums should not be double-prefixed when model has parent" )
259+ public void givenChildModelWithInheritedInnerEnumThenEnumNameIsNotDoublePrefixed () throws Exception {
260+ // This tests that when a child model inherits from a parent that has an inner enum property,
261+ // the enum name is not double-prefixed (e.g., Employee.Employee.ProjectRolesEnum instead of
262+ // Employee.ProjectRolesEnum).
263+ //
264+ // We use typescript-angular because it sets supportsMultipleInheritance=true,
265+ // which means cm.parent will be set for child models using allOf.
266+ // typescript-fetch does NOT support inheritance, so cm.parent is always null there.
267+ final String specPath = "src/test/resources/3_0/issue_22748_inherited_inner_enum.yaml" ;
268+
269+ File output = Files .createTempDirectory ("test" ).toFile ().getCanonicalFile ();
270+ output .deleteOnExit ();
271+
272+ CodegenConfigurator configurator = new CodegenConfigurator ()
273+ .setGeneratorName ("typescript-angular" )
274+ .setInputSpec (specPath )
275+ .setOutputDir (output .getAbsolutePath ());
276+
277+ Generator generator = new DefaultGenerator ();
278+ generator .opts (configurator .toClientOptInput ()).generate ();
279+
280+ // Find the Employee model file (the child model)
281+ Pattern modelDefinition = Pattern .compile ("\\ b(interface|type|class)\\ s+Employee\\ b" );
282+ Path modelFile = findModelDefinitionFile (output .toPath (), modelDefinition );
283+ String fileContents = Files .readString (modelFile );
284+
285+ // Should NOT contain double-prefixed enum name (typescript-angular uses "." separator)
286+ Assert .assertFalse (fileContents .contains ("Employee.Employee.ProjectRolesEnum" ),
287+ "typescript-angular: Should not contain double-prefixed 'Employee.Employee.ProjectRolesEnum' in " + modelFile );
288+
289+ // Should contain correctly prefixed enum name (single prefix with "." separator)
290+ Assert .assertTrue (fileContents .contains ("Employee.ProjectRolesEnum" ),
291+ "typescript-angular: Should contain 'Employee.ProjectRolesEnum' in " + modelFile );
292+ }
293+
258294}
0 commit comments