feat: Impl EndpointArgRegister for Pagination

Signed-off-by: Awiteb <a@4rs.nl>
This commit is contained in:
Awiteb 2024-07-18 10:57:52 +03:00
parent 868ec66b68
commit d0d048c135
Signed by: awiteb
GPG key ID: 3F6B55640AA6682F

View file

@ -26,7 +26,9 @@ use salvo::{
extract::Metadata as ExtractMetadata,
oapi::{
Components as OapiComponents,
EndpointArgRegister,
Object,
Operation as OapiOperation,
Parameter,
ParameterIn,
Parameters,
@ -86,6 +88,14 @@ impl ToParameters<'_> for Pagination {
}
}
impl EndpointArgRegister for Pagination {
fn register(components: &mut OapiComponents, operation: &mut OapiOperation, _arg: &str) {
for parameter in Self::to_parameters(components) {
operation.parameters.insert(parameter);
}
}
}
/// Extract a query parameter from the request
fn extract_query<T: FromStr>(req: &Request, name: &str, default_value: T) -> ApiResult<T>
where