File tree Expand file tree Collapse file tree 2 files changed +11
-17
lines changed
Expand file tree Collapse file tree 2 files changed +11
-17
lines changed Original file line number Diff line number Diff line change @@ -155,8 +155,15 @@ pub(crate) fn hoist_any_of_subschema_with_a_nullable_variant(kube_schema: &mut S
155155 panic ! ( "oneOf is set when there is already an anyOf: {one_of:#?}" ) ;
156156 }
157157
158+ let mut to_hoist = to_hoist. clone ( ) ;
159+ let kube_schema_metadata = kube_schema. metadata . take ( ) ;
160+
161+ if to_hoist. metadata . is_none ( ) {
162+ to_hoist. metadata = kube_schema_metadata;
163+ }
164+
158165 // Replace the schema with the non-null subschema
159- * kube_schema = to_hoist. clone ( ) ;
166+ * kube_schema = to_hoist;
160167
161168 // Set the schema to nullable (as we know we matched the null variant earlier)
162169 // TODO (@NickLarsenNZ): Do we need to insert `nullable` into `other` too?
Original file line number Diff line number Diff line change @@ -371,7 +371,6 @@ pub(crate) fn hoist_properties_for_any_of_subschemas(kube_schema: &mut SchemaObj
371371 ( Some ( _) , Some ( _) ) => panic ! ( "oneOf and anyOf are mutually exclusive" ) ,
372372 } ;
373373
374-
375374 if subschemas. is_empty ( ) {
376375 return ;
377376 }
@@ -419,23 +418,11 @@ pub(crate) fn hoist_properties_for_any_of_subschemas(kube_schema: &mut SchemaObj
419418 // Kubernetes doesn't allow variants to set additionalProperties
420419 object. additional_properties . take ( ) ;
421420
422- // For a tagged enum, we need to preserve the variant description
421+ // For a tagged enum (oneOf) , we need to preserve the variant description
423422 if preserve_description {
424- assert_eq ! (
425- object. properties. len( ) ,
426- 1 ,
427- "Expecting only a single property defined for the tagged enum variant schema"
428- ) ;
429-
430- if let Schema :: Object ( subschema) = object
431- . properties
432- . values_mut ( )
433- . next ( )
434- . expect ( "asserted that one and only one property exists" )
435- {
423+ if let Some ( Schema :: Object ( subschema) ) = object. properties . values_mut ( ) . next ( ) {
436424 if let Some ( Metadata {
437- description : Some ( _d) ,
438- ..
425+ description : Some ( _) , ..
439426 } ) = metadata. as_deref ( )
440427 {
441428 subschema. metadata = metadata
You can’t perform that action at this time.
0 commit comments