Browse Source
Fixes #12419 **Problem:** The documentation section "Required, can be None" was misleading. It suggested that you could force clients to send a None value, but HTTP query parameters cannot send literal None - they're either strings or omitted entirely. The example showed `q: Annotated[str | None, Query(min_length=3)]` without a default value, which makes the parameter required. However, there's no way for a client to satisfy this by sending None via HTTP query parameters. **Solution:** Updated the documentation to: 1. Rename the section to "Required with None type" to be more accurate 2. Add a detailed note explaining HTTP query parameter limitations 3. Clarify that omitting the parameter results in a validation error 4. Explain this pattern is more useful for dependencies than HTTP endpoints 5. Show the correct pattern for optional parameters that can be omitted **Testing:** The existing tests in test_tutorial006c.py are already marked as xfail with a reference to this issue, confirming the example doesn't work as described. This documentation update clarifies the behavior instead of changing the example to something that would work differently. This helps developers understand when to use this pattern (dependencies) vs when to use optional parameters with defaults (HTTP endpoints).pull/14871/head
1 changed files with 16 additions and 4 deletions
Loading…
Reference in new issue