Describe the bug
When I try to pass a function to auth I receive an error from Pydantic about it being Unable to generate pydantic-core schema for <class 'function'>.
Versions (please complete the following information):
Python version: 3.10
Django version: 4.2.5
Django-Ninja version: 1.0.1
Pydantic version: 2.4.1
Detailed description
When I try to run this snippet that's specified in the official documentation:
def ip_whitelist(request):
if request.META["REMOTE_ADDR"] == "8.8.8.8":
return "8.8.8.8"
@api.get("/ipwhiltelist", auth=ip_whitelist)
def ipwhiltelist(request):
return f"Authenticated client, IP = {request.auth}"
I run into the following problem:
_pydantic.errors.PydanticSchemaGenerationError: Unable to generate pydantic-core schema for <class 'function'>. Set \arbitrary_types_allowed=True\ in the model_config to ignore this error or implement `__get_pydantic_core_schema__` on your type to fully support it.``
If you got this error by calling handler(<some type>) within \__get_pydantic_core_schema__\ then you likely need to call `handler.generate_schema(<some type>)` since we do not call `__get_pydantic_core_schema__` on `<some type>` otherwise to avoid infinite recursion.``_
Describe the bug When I try to pass a function to auth I receive an error from Pydantic about it being
Unable to generate pydantic-core schema for <class 'function'>.
Versions (please complete the following information):
Detailed description When I try to run this snippet that's specified in the official documentation:
I run into the following problem: