add special case generation of PostTextResponse slots field
@@ -34,7 +34,11 @@ pub trait GenerateProtocol {
/// Generate the various `use` statements required by the module generatedfor this service
fn generate_prelude(&self, writer: &mut FileWriter, service: &Service<'_>) -> IoResult;
- fn generate_method_signatures(&self, writer: &mut FileWriter, service: &Service<'_>) -> IoResult;
+ fn generate_method_signatures(
+ &self,
+ writer: &mut FileWriter,
+ service: &Service<'_>,
+ ) -> IoResult;
/// Generate a method for each `Operation` in the `Service` to execute that method remotely
///
@@ -318,9 +322,8 @@ pub fn mutate_type_name_for_streaming(type_name: &str) -> String {
fn find_shapes_to_generate(service: &Service<'_>) -> BTreeSet<String> {
let mut shapes_to_generate = BTreeSet::<String>::new();
- let mut visitor = |shape_name: &str, _shape: &Shape| {
- shapes_to_generate.insert(shape_name.to_owned())
- };
+ let mut visitor =
+ |shape_name: &str, _shape: &Shape| shapes_to_generate.insert(shape_name.to_owned());
for (_, operation) in service.operations() {
if let Some(ref input) = operation.input {
service.visit_shapes(&input.shape, &mut visitor);
@@ -337,7 +340,11 @@ fn find_shapes_to_generate(service: &Service<'_>) -> BTreeSet<String> {
return shapes_to_generate;
}
-fn generate_types<P>(writer: &mut FileWriter, service: &Service<'_>, protocol_generator: &P) -> IoResult
+fn generate_types<P>(
+ writer: &mut FileWriter,
+ service: &Service<'_>,
+ protocol_generator: &P,
+) -> IoResult
where
P: GenerateProtocol,
{
@@ -556,6 +563,10 @@ fn generate_struct_fields<P: GenerateProtocol>(
// See https://github.com/rusoto/rusoto/issues/1419 for more information
if service.name() == "CodePipeline" && shape_name == "ActionRevision" && name == "revision_change_id" || name == "created" {
lines.push(format!("pub {}: Option<{}>,", name, rs_type))
+ // In pratice, Lex can return null values for slots that are not filled. The documentation
+ // does not mention that the slot values themselves can be null.
+ } if service.name() == "Amazon Lex Runtime Service" && shape_name == "PostTextResponse" && name == "slots"{
+ lines.push(format!("pub {}: Option<::std::collections::HashMap<String, Option<String>>>,", name))
} else if shape.required(member_name) {
lines.push(format!("pub {}: {},", name, rs_type))
} else if name == "type" {
