-
-
Notifications
You must be signed in to change notification settings - Fork 46
Open
Description
Describe the bug
The validate function should check the type of the passed in schema.
In my case doing this:
import sanic as s
from sanic_ext import validate
class MyRESTMethodArgs:
id : str
@bp.post('/create')
@validate(json=MyRESTMethodArgs)
async def post_create(req : s.Request, body : MyRESTMethodArgs):
pass # Business logicFails miserably with:
File "<irrelevant>\.venv\Lib\site-packages\sanic_ext\extras\validation\decorator.py", line 73, in decorated_function
retval = f(*args, **kwargs)
Inspecting it closer, it turns out schemas looks like this:
{'json': {}, 'form': None, 'query': None}I assume the issue is with generate_schema for some reason just returning {} instead of raising an exception
To Reproduce
See above
Expected behavior
validate should fail if it encounters a schema model it can't process (As according to the docs, a simple Python class can't be used)
Environment (please complete the following information):
mode: debug, single worker
server: sanic, HTTP/1.1
python: 3.12.4
platform: Windows-11-10.0.22631-SP0
packages: sanic-routing==23.12.0, sanic-ext==23.12.0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels