Describe the bug
The value of required attribute for the x-api-version header has changed
from true to false between versions 5.2.0 and 5.2.1.
To Reproduce
Consider this simple snippet (let's call it 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)
res = client.get("/openapi.json?version=2023-04-14")
openapi_dict = res.json()
params = openapi_dict["paths"]["/foo"]["get"]["parameters"][0]
assert params["name"] == "x-api-version", params
assert params["required"] is True, params
when you run it like this:
uvx --with 'cadwyn[standard]==5.2.0' pytest app.py
the test will pass, but with:
uvx --with 'cadwyn[standard]==5.2.1' pytest app.py
it fails.
Expected behavior
Even though the paramater now has a default value, I think the semantics of required in OAS 3.1 are meant for the server (not the client) to provide that default value when client omits it (because it's not required). Currently that's not what's happening, because if the client won't specify the version header, the server responds with 404 (obviously).
Additional context
I guess this is not a huge issue as I think every client code generator will add the default automatically.
Describe the bug
The value of
requiredattribute for thex-api-versionheader has changedfrom
truetofalsebetween versions 5.2.0 and 5.2.1.To Reproduce
Consider this simple snippet (let's call it
app.py):when you run it like this:
the test will pass, but with:
it fails.
Expected behavior
Even though the paramater now has a
defaultvalue, I think the semantics ofrequiredin OAS 3.1 are meant for the server (not the client) to provide that default value when client omits it (because it's not required). Currently that's not what's happening, because if the client won't specify the version header, the server responds with 404 (obviously).Additional context
I guess this is not a huge issue as I think every client code generator will add the default automatically.