@@ -88,6 +88,9 @@ public ScalaHttp4sClientCodegen() {
8888 SchemaSupportFeature .Polymorphism ,
8989 SchemaSupportFeature .not
9090 )
91+ .includeSchemaSupportFeatures (
92+ SchemaSupportFeature .oneOf
93+ )
9194 .excludeParameterFeatures (
9295 ParameterFeature .Cookie ,
9396 ParameterFeature .FormMultipart
@@ -390,8 +393,10 @@ public Map<String, ModelsMap> postProcessAllModels(Map<String, ModelsMap> objs)
390393 Set <String > additionalImports = new HashSet <>();
391394 for (String childName : cModel .oneOf ) {
392395 CodegenModel childModel = allModels .get (childName );
393- if (childModel != null && oneOfMemberCount .getOrDefault (childName , 0 ) == 1 ) {
394- // Mark for inlining (only used by this one parent)
396+ if (childModel != null
397+ && (childModel .oneOf == null || childModel .oneOf .isEmpty ())
398+ && oneOfMemberCount .getOrDefault (childName , 0 ) == 1 ) {
399+ // Mark for inlining (only used by this one parent, and not itself a oneOf container)
395400 childModel .getVendorExtensions ().put ("x-isOneOfMember" , true );
396401 childModel .getVendorExtensions ().put ("x-oneOfParent" , cModel .classname );
397402 // Store parent's discriminator info for use in template
@@ -407,6 +412,20 @@ public Map<String, ModelsMap> postProcessAllModels(Map<String, ModelsMap> objs)
407412 }
408413 }
409414
415+ // Create list of discriminator entries with class names and schema names
416+ // When discriminator has no explicit mapping, use schema name (not class name)
417+ List <Map <String , String >> discriminatorEntries = new ArrayList <>();
418+ for (String childName : cModel .oneOf ) {
419+ CodegenModel childModel = allModels .get (childName );
420+ if (childModel != null ) {
421+ Map <String , String > entry = new HashMap <>();
422+ entry .put ("classname" , childModel .classname );
423+ entry .put ("schemaName" , childModel .name );
424+ discriminatorEntries .add (entry );
425+ }
426+ }
427+ cModel .getVendorExtensions ().put ("x-discriminator-entries" , discriminatorEntries );
428+
410429 // Decide between sealed trait (with inlined members) vs regular trait (edge cases)
411430 // Use sealed trait ONLY if ALL oneOf members can be inlined
412431 // If some are inlined and some aren't (mixed case), use regular trait
0 commit comments