@@ -295,6 +295,61 @@ public void resolveInlineModelDeduplicatesMultipleRefsToSameExternalFile() {
295295 assertNull ("Duplicate Deletion_Request_1 must not exist" , schemas .get ("Deletion_Request_1" ));
296296 }
297297
298+ @ Test
299+ public void resolveInlineModelKeepsUntitledSchemasDifferingOnlyByDescriptionDistinct () {
300+ // Regression test for #24004: two distinct *untitled* inline object schemas that differ
301+ // only in their descriptions (here the nested 'result' property: "ABC Result" vs
302+ // "DEF Result") must NOT be merged. The volatile-stripped structural-signature fallback in
303+ // matchGenerated() collapses them once description/type are removed; that fallback is only
304+ // intended to unify titled named types across parser volatility, so it must not fire for
305+ // untitled inline schemas — otherwise 'def' silently gets the type generated for 'abc' and
306+ // breaks user code that expects two separate types (regression introduced in 7.23).
307+ OpenAPI openapi = new OpenAPI ();
308+ openapi .setComponents (new Components ());
309+ openapi .setPaths (new Paths ());
310+
311+ Schema abc = new ObjectSchema ()
312+ .description ("first container" )
313+ .addProperty ("result" , new StringSchema ().description ("ABC Result" ));
314+ Schema def = new ObjectSchema ()
315+ .description ("second container" )
316+ .addProperty ("result" , new StringSchema ().description ("DEF Result" ));
317+
318+ Schema response = new ObjectSchema ()
319+ .addProperty ("abc" , abc )
320+ .addProperty ("def" , def );
321+
322+ ApiResponse apiResponse = new ApiResponse ()
323+ .description ("OK" )
324+ .content (new Content ().addMediaType ("application/json" ,
325+ new MediaType ().schema (response )));
326+
327+ openapi .getPaths ().addPathItem ("/default" , new PathItem ().get (
328+ new Operation ().operationId ("apiGetDefault" )
329+ .responses (new ApiResponses ().addApiResponse ("200" , apiResponse ))));
330+
331+ new InlineModelResolver ().flatten (openapi );
332+
333+ // Locate the flattened response model (the only component schema carrying both properties).
334+ Schema responseModel = null ;
335+ for (Schema candidate : openapi .getComponents ().getSchemas ().values ()) {
336+ if (candidate .getProperties () != null
337+ && candidate .getProperties ().containsKey ("abc" )
338+ && candidate .getProperties ().containsKey ("def" )) {
339+ responseModel = candidate ;
340+ break ;
341+ }
342+ }
343+ assertNotNull ("Flattened response model with abc/def properties must exist" , responseModel );
344+
345+ String abcRef = ((Schema ) responseModel .getProperties ().get ("abc" )).get$ref ();
346+ String defRef = ((Schema ) responseModel .getProperties ().get ("def" )).get$ref ();
347+ assertNotNull ("abc property must be a $ref to a generated schema" , abcRef );
348+ assertNotNull ("def property must be a $ref to a generated schema" , defRef );
349+ assertFalse ("abc and def must resolve to DISTINCT schemas, not be merged: " + abcRef ,
350+ abcRef .equals (defRef ));
351+ }
352+
298353 @ Test
299354 public void resolveInlineModel2DifferentInnerModelsWithSameTitle () {
300355 OpenAPI openapi = new OpenAPI ();
0 commit comments