message: Refactor if let clauses. Removed extended docs
diff: @@ -37,108 +37,23 @@ impl Visitor for StructuralSchemaRewriter {
  .object
  .get_or_insert_with(|| Box::new(ObjectValidation::default()));
  for variant in one_of {
  - // If we provide descriptions for enum variants it will produce invalid CRDs like in the following example
  - //
  - // #[derive(Serialize, Deserialize, Debug, PartialEq, Clone, JsonSchema)]
  - // #[serde(rename_all = "camelCase")]
  - // enum ComplexEnum {
  - // /// First variant with an int
  - // VariantOne { int: i32 },
  - // /// Second variant which doesn't has an attribute
  - // VariantTwo {}
  - // }
  - //
  - // This produces the following invalid CRD (snippet)
  - // "complexEnum": {
  - // "type": "object",
  - // "properties": {
  - // "variantOne": {
  - // "type": "object",
  - // "properties": {
  - // "int": {
  - // "type": "integer",
  - // "format": "int32"
  - // }
  - // },
  - // "required": ["int"],
  - // },
  - // "VariantTwo": {
  - // "type": "object",
  - // }
  - // },
  - // "oneOf": [
  - // {
  - // "required": ["variantOne"],
  - // "description": "First variant with an int"
  - // },
  - // {
  - // "required": ["variantTwo"],
  - // "description": "Second variant which doesn't has an attribute"
  - // }
  - // ],
  - // "description": "This is a complex enum"
  - // }
  - //
  - // The correct solution requires to move the description from the oneOf section to to the complexEnum.properties
  - // The corrected solution looks like follows
  - // "complexEnum": {
  - // "type": "object",
  - // "properties": {
  - // "variantOne": {
  - // "type": "object",
  - // "properties": {
  - // "int": {
  - // "type": "integer",
  - // "format": "int32"
  - // }
  - // },
  - // "required": ["int"],
  - // "description": "First variant with an int"
  - // },
  - // "variantTwo": {
  - // "type": "object",
  - // "description": "Second variant which doesn't has an attribute"
  - // }
  - // },
  - // "oneOf": [
  - // {
  - // "required": ["variantOne"],
  - // },
  - // {
  - // "required": ["variantTwo"],
  - // }
  - // ],
  - // "description": "This is a complex enum"
  - // }
  - //
  - // The following lines move the descriptions to the correct places
  if let Schema::Object(SchemaObject {
  - metadata: Some(variant_metadata),
  + instance_type: variant_type,
  object: Some(variant_obj),
  + metadata: variant_metadata,
  ..
  }) = variant
  {
  + if let Some(variant_metadata) = variant_metadata {
  + // Move enum variant description from oneOf clause to its corresponding property
  if let Some(description) = std::mem::take(&mut variant_metadata.description) {
  - match only_item(variant_obj.properties.values_mut()) {
  - None => panic!(
  - "the list of properties in {:?} was expected to only contain a single property: the variant of an enum",
  - variant_obj.properties
  - ),
  - Some(Schema::Object(variant_object)) => {
  + if let Some(Schema::Object(variant_object)) = only_item(variant_obj.properties.values_mut()) {
  let metadata = variant_object.metadata.get_or_insert_with(|| Box::new(Metadata::default()));
  metadata.description = Some(description.to_string());
  - },
  - Some(Schema::Bool(_)) => {},
  - };
  + }
  }
  }
  - if let Schema::Object(SchemaObject {
  - instance_type: variant_type,
  - object: Some(variant_obj),
  - ..
  - }) = variant
  - {
  // Move all properties
  let variant_properties = std::mem::take(&mut variant_obj.properties);
  for (property_name, property) in variant_properties {
  