diff --git a/codegen/src/dto.rs b/codegen/src/dto.rs index bc30a3ce..f4b9bd27 100644 --- a/codegen/src/dto.rs +++ b/codegen/src/dto.rs @@ -202,17 +202,11 @@ pub fn collect_rust_types(model: &smithy::Model, ops: &Operations) -> RustTypes }; fields.push(field); } - - let s3_unwrapped_xml_output = ops - .iter() - .any(|(_, op)| op.s3_unwrapped_xml_output && op.output == rs_shape_name); - let ty = rust::Type::Struct(rust::Struct { name: rs_shape_name.clone(), fields, doc: shape.traits.doc().map(ToOwned::to_owned), - s3_unwrapped_xml_output, xml_name: shape.traits.xml_name().map(o), is_error_type: shape.traits.error().is_some(), }); @@ -264,7 +258,6 @@ fn patch_types(space: &mut RustTypes) { name: ty.name.clone(), fields: ty.fields.iter().filter(|x| x.position == "xml").cloned().collect(), doc: ty.doc.clone(), - s3_unwrapped_xml_output: false, xml_name: None, is_error_type: false, }; @@ -304,7 +297,6 @@ fn unify_operation_types(ops: &Operations, space: &mut RustTypes) { name: op.input.clone(), fields: default(), doc: None, - s3_unwrapped_xml_output: false, xml_name: None, is_error_type: false, } @@ -324,7 +316,6 @@ fn unify_operation_types(ops: &Operations, space: &mut RustTypes) { name: op.output.clone(), fields: default(), doc: None, - s3_unwrapped_xml_output: false, xml_name: None, is_error_type: false, } diff --git a/codegen/src/rust.rs b/codegen/src/rust.rs index 8c5a6c17..bcbbf76e 100644 --- a/codegen/src/rust.rs +++ b/codegen/src/rust.rs @@ -68,7 +68,6 @@ pub struct Struct { pub name: String, pub fields: Vec, pub doc: Option, - pub s3_unwrapped_xml_output: bool, pub xml_name: Option, pub is_error_type: bool, diff --git a/codegen/src/xml.rs b/codegen/src/xml.rs index 4895aa2d..ba9365a0 100644 --- a/codegen/src/xml.rs +++ b/codegen/src/xml.rs @@ -154,8 +154,11 @@ fn codegen_xml_ser(ops: &Operations, rust_types: &RustTypes) { g!("s.timestamp(\"{}\", &self.{}, TimestampFormat::{})?;", xml_name, field.name, fmt); } } else if field.option_type { + let s3_unwrapped_xml_output = + ops.iter().any(|(_, op)| op.s3_unwrapped_xml_output && op.output == ty.name); + g!("if let Some(ref val) = self.{} {{", field.name); - if ty.s3_unwrapped_xml_output { + if s3_unwrapped_xml_output { g!("val.serialize_content(s)?;"); } else { g!("s.content(\"{xml_name}\", val)?;");