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

Fix Option<Query<T>> type support #678

Merged
merged 1 commit into from
Jul 14, 2023
Merged

Conversation

juhaku
Copy link
Owner

@juhaku juhaku commented Jul 14, 2023

Fix Option<Query<T>> for primitive types. Prior to this commit defining before mentioned type as an argument to path operation handler caused a compile error in 3.4.0 release. This bug has been there before but it manifested only after the changes regarding automatic query parameter detection was made.

This commit allows optional query parameters for handler function:

 async fn get_item(id: Option<Query<u32>>) {}

Note! The automatic query parameter detection does not work for primitive types on axum and in actix_web frameworks because it has never been implemented. It will always be expected to work with IntoParams trait. This said with these frameworks the primitive query parameters if not used with IntoParams must be declared manually to the #[utoipa::path(params(...))] macro as input arguments.

Resolves #677 Resolves #675

Fix `Option<Query<T>>` for primitive types. Prior to this commit
defining before mentioned type as an argument to path operation handler
caused a compile error in 3.4.0 release. This bug has been there before
but it manifested only after the changes regarding automatic query
parameter detection was made.

This commit allows optional query parameters for handler function:
```rust
 async fn get_item(id: Option<Query<u32>>) {}
```

**Note!** The automatic query parameter detection does not work for
primitive types on `axum` and in `actix_web` frameworks because it has
never been implemented. They will always be expected to work with
`IntoParams` trait. This said with these frameworks the primitive query
parameters if not used with `IntoParams` must be declared manually to
the `#[utoipa::path(params(...))]` macro as input arguments.
@juhaku juhaku merged commit 99020a9 into master Jul 14, 2023
@juhaku juhaku deleted the fix-option-query-parameter branch July 14, 2023 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Released
1 participant