@@ -328,7 +328,7 @@ impl Transform for StructuralSchemaRewriter {
328328 if let Some ( subschemas) = & mut schema. subschemas {
329329 if let Some ( one_of) = subschemas. one_of . as_mut ( ) {
330330 // Tagged enums are serialized using `one_of`
331- hoist_subschema_properties ( one_of, & mut schema. object , & mut schema. instance_type ) ;
331+ hoist_subschema_properties ( one_of, & mut schema. object , & mut schema. instance_type , true ) ;
332332
333333 // "Plain" enums are serialized using `one_of` if they have doc tags
334334 hoist_subschema_enum_values ( one_of, & mut schema. enum_values , & mut schema. instance_type ) ;
@@ -340,7 +340,8 @@ impl Transform for StructuralSchemaRewriter {
340340
341341 if let Some ( any_of) = & mut subschemas. any_of {
342342 // Untagged enums are serialized using `any_of`
343- hoist_subschema_properties ( any_of, & mut schema. object , & mut schema. instance_type ) ;
343+ // Variant descriptions are not pushed into properties (because they are not for the field).
344+ hoist_subschema_properties ( any_of, & mut schema. object , & mut schema. instance_type , false ) ;
344345 }
345346 }
346347
@@ -499,6 +500,7 @@ fn hoist_subschema_properties(
499500 subschemas : & mut Vec < Schema > ,
500501 common_obj : & mut Option < Box < ObjectValidation > > ,
501502 instance_type : & mut Option < SingleOrVec < InstanceType > > ,
503+ push_description_to_property : bool ,
502504) {
503505 for variant in subschemas {
504506 if let Schema :: Object ( SchemaObject {
@@ -518,7 +520,9 @@ fn hoist_subschema_properties(
518520 let metadata = variant_object
519521 . metadata
520522 . get_or_insert_with ( Box :: < Metadata > :: default) ;
521- metadata. description = Some ( description) ;
523+ if push_description_to_property {
524+ metadata. description = Some ( description) ;
525+ }
522526 }
523527
524528 // Move all properties
0 commit comments