mwapi_responses 0.5.1

Automatically generate strict types for MediaWiki API responses
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
pub async fn test<T: serde::de::DeserializeOwned>(
    params: &[(&str, &str)],
) -> anyhow::Result<T> {
    eprintln!("params: {}", serde_urlencoded::to_string(params)?);
    let client = reqwest::Client::builder()
        .user_agent("mwapi_responses testing")
        .build()?;
    let resp = client
        .get("https://en.wikipedia.org/w/api.php")
        .query(params)
        .send()
        .await?
        .text()
        .await?;
    eprintln!("response: {}", &resp);
    Ok(serde_json::from_str(&resp)?)
}