Skip to content

Commit

Permalink
Remove field in struct type
Browse files Browse the repository at this point in the history
  • Loading branch information
nomick committed Jan 21, 2024
1 parent 8d86130 commit d786ea1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
9 changes: 0 additions & 9 deletions codegen/src/dto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
});
Expand Down Expand Up @@ -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,
};
Expand Down Expand Up @@ -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,
}
Expand All @@ -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,
}
Expand Down
1 change: 0 additions & 1 deletion codegen/src/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ pub struct Struct {
pub name: String,
pub fields: Vec<StructField>,
pub doc: Option<String>,
pub s3_unwrapped_xml_output: bool,

pub xml_name: Option<String>,
pub is_error_type: bool,
Expand Down
5 changes: 4 additions & 1 deletion codegen/src/xml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;");
Expand Down

0 comments on commit d786ea1

Please sign in to comment.