Skip to content

Commit

Permalink
feat: impl Paginable for all list items
Browse files Browse the repository at this point in the history
  • Loading branch information
arlyon committed Jun 3, 2022
1 parent 2dc1a68 commit e05872b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions openapi/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,24 @@ pub fn gen_inferred_params(
out.push_str(" }\n");
out.push_str(" }\n");
out.push_str("}\n");

// we implement paginate on lists that have an Id
if let ("list", Some(_)) = (params.method.as_str(), &id_type) {
state.use_params.insert("Paginable");

out.push_str("impl Paginable for ");
out.push_str(&params.rust_type);
out.push_str("<'_> {\n");
out.push_str(" type O = ");
out.push_str(&struct_name);
out.push_str(";\n");
out.push_str(
" fn set_last(&mut self, item: Self::O) {
self.starting_after = Some(item.id());
}",
);
out.push_str("}");
}
}
}

Expand Down

0 comments on commit e05872b

Please sign in to comment.