-
Notifications
You must be signed in to change notification settings - Fork 47
Open
Description
Describe the bug
The comment from
Lines 127 to 128 in ca3f3a1
| # We return it because we will be returning the **matched** version, not the requested one. | |
| # In date-based versioning with waterfalling, it makes sense. |
x-api-version header in the response seems to have the same value as the one in the request, not the closest matched version determined by "waterfalling".
To Reproduce
This test (app.py):
from cadwyn import Cadwyn, Version, VersionBundle, VersionedAPIRouter
versions = VersionBundle(Version("2023-04-14"), Version("2022-11-16"))
app = Cadwyn(
versions=versions,
)
router = VersionedAPIRouter()
@router.get("/foo")
def foo():
return "foo"
app.generate_and_include_versioned_routers(router)
def test_param():
from fastapi.testclient import TestClient
client = TestClient(app, headers={"x-api-version": "2024-01-01"})
res = client.get("/foo")
assert res.json() == "foo"
assert res.headers["x-api-version"] == "2023-04-14"when run like this:
uvx --with 'cadwyn[standard]' pytest app.pyfails.
Expected behavior
As per linked comment, I'd expect the version header value to be 2023-04-14 when I passed 2024-01-01 in the request.
Additional context
Looks like this never worked (? 🤔). The earliest version I can test with this snippet is 4.3.
Metadata
Metadata
Assignees
Labels
No labels