Skip to content

Commit 4ab36e6

Browse files
CopilotNugine
andcommitted
Fix optional_object_attributes to be Optional in ListObjectsV2Input
Co-authored-by: Nugine <[email protected]>
1 parent d8fdc97 commit 4ab36e6

File tree

14 files changed

+62843
-63097
lines changed

14 files changed

+62843
-63097
lines changed

codegen/src/v1/aws_conv.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,6 @@ pub fn codegen(ops: &Operations, rust_types: &RustTypes) {
103103
let field_ty = &rust_types[field.type_.as_str()];
104104

105105
let needs_unwrap = 'unwrap: {
106-
if field.type_ == "OptionalObjectAttributesList" {
107-
break 'unwrap true;
108-
}
109106
if is_op_input(&ty.name, ops) && field.option_type.not() && field.is_required {
110107
break 'unwrap true;
111108
}

codegen/src/v1/dto.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ pub fn collect_rust_types(model: &smithy::Model, ops: &Operations) -> RustTypes
152152
}
153153
if is_op_input && is_required.not() {
154154
if field_type.ends_with("List") {
155+
// Exception: OptionalObjectAttributesList should be optional
156+
if field_type == "OptionalObjectAttributesList" {
157+
break 'optional true;
158+
}
155159
break 'optional false;
156160
}
157161
break 'optional true;

codegen/src/v1/ops.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -425,13 +425,21 @@ fn codegen_op_http_de(op: &Operation, rust_types: &RustTypes) {
425425
let field_type = &rust_types[&field.type_];
426426

427427
if let rust::Type::List(_) = field_type {
428-
assert!(field.option_type.not());
429-
g!(
430-
"let {}: {} = http::parse_list_header(req, &{header}, {})?;",
431-
field.name,
432-
field.type_,
433-
field.is_required
434-
);
428+
if field.option_type {
429+
// Special case for optional list headers (e.g., OptionalObjectAttributesList)
430+
g!(
431+
"let {}: Option<{}> = http::parse_opt_list_header(req, &{header})?;",
432+
field.name,
433+
field.type_
434+
);
435+
} else {
436+
g!(
437+
"let {}: {} = http::parse_list_header(req, &{header}, {})?;",
438+
field.name,
439+
field.type_,
440+
field.is_required
441+
);
442+
}
435443
} else if let rust::Type::Timestamp(ts_ty) = field_type {
436444
assert!(field.option_type);
437445
let fmt = ts_ty.format.as_deref().unwrap_or("HttpDate");

0 commit comments

Comments
 (0)