poem
poem copied to clipboard
What is the expect behavior of `Path<Vec<T>>` in openapi
I describe an API like this:
#[OpenApi]
impl Api {
/// Return status code or random status code if more than one is given
#[oai(
path = "/status/:codes",
method = "get",
tag = "ApiTags::StatusCodes"
)]
async fn status(&self, codes: Path<Vec<u16>>) -> StatusRes {
if codes.len() > 1 {
let mut rng = rand::thread_rng();
let idx = rng.gen_range(0..codes.len());
StatusRes::from(codes[idx])
} else {
StatusRes::from(codes[0])
}
}
}
I expect usage like /status/200,300,400
or so. And the above code will lead to array[integer]
in swagger.
But when really receiving requests like 200,300
, it seems there is no parse_from_parameter(&str)
for Vec<T>
and come across this error:
failed to parse path `codes`: failed to parse "integer(uint16)": invalid digit found in string (occurred while parsing "[integer(uint16)]")
Did I misunderstand or is this a bug?
This is not supported right now and I need to think about how to do it.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
This issue was closed because it has been stalled for 5 days with no activity.