self.include_in_schema = include_in_schema
self.response_class = response_class
- assert inspect.isfunction(endpoint) or inspect.ismethod(
- endpoint
- ), f"An endpoint must be a function or method"
+ assert callable(endpoint), f"An endpoint must be a callable"
self.dependant = get_dependant(path=self.path_format, call=self.endpoint)
for depends in self.dependencies[::-1]:
self.dependant.dependencies.insert(
--- /dev/null
+from functools import partial
+
+from fastapi import FastAPI
+from starlette.testclient import TestClient
+
+
+def main(some_arg, q: str = None):
+ return {"some_arg": some_arg, "q": q}
+
+
+endpoint = partial(main, "foo")
+
+app = FastAPI()
+
+app.get("/")(endpoint)
+
+
+client = TestClient(app)
+
+
+def test_partial():
+ response = client.get("/?q=bar")
+ data = response.json()
+ assert data == {"some_arg": "foo", "q": "bar"}