mirror of
https://github.com/fastapi/fastapi.git
synced 2026-02-10 06:11:25 -05:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8bdb0d2242 | ||
|
|
df950111fe | ||
|
|
363aced75a | ||
|
|
66dc695071 | ||
|
|
e94028ab60 | ||
|
|
8fd291465b |
1
.github/workflows/test.yml
vendored
1
.github/workflows/test.yml
vendored
@@ -14,6 +14,7 @@ on:
|
||||
|
||||
env:
|
||||
UV_NO_SYNC: true
|
||||
INLINE_SNAPSHOT_DEFAULT_FLAGS: review
|
||||
|
||||
jobs:
|
||||
changes:
|
||||
|
||||
@@ -7,6 +7,15 @@ hide:
|
||||
|
||||
## Latest Changes
|
||||
|
||||
### Features
|
||||
|
||||
* ✨ Show a clear error on attempt to include router into itself. PR [#14258](https://github.com/fastapi/fastapi/pull/14258) by [@JavierSanchezCastro](https://github.com/JavierSanchezCastro).
|
||||
* ✨ Replace `dict` by `Mapping` on `HTTPException.headers`. PR [#12997](https://github.com/fastapi/fastapi/pull/12997) by [@rijenkii](https://github.com/rijenkii).
|
||||
|
||||
### Internal
|
||||
|
||||
* 🔧 Configure `test` workflow to run tests with `inline-snapshot=review`. PR [#14876](https://github.com/fastapi/fastapi/pull/14876) by [@YuriiMotov](https://github.com/YuriiMotov).
|
||||
|
||||
## 0.128.6
|
||||
|
||||
### Fixes
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from collections.abc import Sequence
|
||||
from collections.abc import Mapping, Sequence
|
||||
from typing import Annotated, Any, Optional, TypedDict, Union
|
||||
|
||||
from annotated_doc import Doc
|
||||
@@ -68,7 +68,7 @@ class HTTPException(StarletteHTTPException):
|
||||
),
|
||||
] = None,
|
||||
headers: Annotated[
|
||||
Optional[dict[str, str]],
|
||||
Optional[Mapping[str, str]],
|
||||
Doc(
|
||||
"""
|
||||
Any headers to send to the client in the response.
|
||||
|
||||
@@ -1393,6 +1393,10 @@ class APIRouter(routing.Router):
|
||||
app.include_router(internal_router)
|
||||
```
|
||||
"""
|
||||
assert self is not router, (
|
||||
"Cannot include the same APIRouter instance into itself. "
|
||||
"Did you mean to include a different router?"
|
||||
)
|
||||
if prefix:
|
||||
assert prefix.startswith("/"), "A path prefix must start with '/'"
|
||||
assert not prefix.endswith("/"), (
|
||||
|
||||
12
tests/test_router_circular_import.py
Normal file
12
tests/test_router_circular_import.py
Normal file
@@ -0,0 +1,12 @@
|
||||
import pytest
|
||||
from fastapi import APIRouter
|
||||
|
||||
|
||||
def test_router_circular_import():
|
||||
router = APIRouter()
|
||||
|
||||
with pytest.raises(
|
||||
AssertionError,
|
||||
match="Cannot include the same APIRouter instance into itself. Did you mean to include a different router?",
|
||||
):
|
||||
router.include_router(router)
|
||||
Reference in New Issue
Block a user