Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get nested objects when retrieving query parameters with Query? #866

Open
jctaveras opened this issue Aug 15, 2024 · 0 comments
Open
Labels
question Further information is requested

Comments

@jctaveras
Copy link

First of all, thank you for this awesome crate. With that being said, I was wondering how do I get nested objects when retrieving query parameters with Query based on the Parameter Serialization standard?

Let's say we have the following:

use poem::web::Query;
use poem_openapi::OpenApi;

#[derive(Deserialize, Object)]
pub struct Search {
    #[oai(rename = "search[term]")]
    pub term: String,
    #[oai(rename = "search[columns]")]
    pub columns: Vec<String>
}

#[derive(Deserialize)]
pub struct Params {
    pub limit: Option<i64>,
    pub search: Option<Search>
}

pub struct API;

#[OpenApi]
impl API {
    #[oai(path = "/", method = "get")]
    fn async fn with_search(&self, Query(params): Query<Params>) {
        // curl http://localhost:PORT/?search[term]=foo&search[columns]=bar,baz
        println!("{:?}",  params.search) // None
    }
}

Is this supported?

@jctaveras jctaveras added the question Further information is requested label Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant