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

Query parameter arrays don't parse correctly #721

Closed
tasn opened this issue Jan 25, 2022 · 3 comments
Closed

Query parameter arrays don't parse correctly #721

tasn opened this issue Jan 25, 2022 · 3 comments

Comments

@tasn
Copy link
Contributor

tasn commented Jan 25, 2022

Bug Report

Version

├── axum v0.4.4
│ ├── axum-core v0.1.1

Platform

Linux p15s 5.16.2-arch1-1 #1 SMP PREEMPT Thu, 20 Jan 2022 16:18:29 +0000 x86_64 GNU/Linux

Description

If you look at https://swagger.io/docs/specification/serialization/#query you'll see that the standard OpenAPI setting for query parameters is explode=true. What does that mean? It means that parameters are passed like this:

http://example.com?arr=item1&arr=item2

Axum however treats queries as a map and doesn't correctly parse these into an array. Instead it just uses the last one.

Expected:

arr: ["item1", "item2"]

Actual:

arr: "item2"
@davidpdrsn
Copy link
Member

See #504

@tasn
Copy link
Contributor Author

tasn commented Jan 25, 2022

Sorry, and thanks!

@huntc
Copy link

huntc commented Jan 24, 2024

As this turned up first on Google for me, https://github.com/tokio-rs/axum/tree/main/axum-extra's Query declaration supports multi-valued query params.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants