-
-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] validate
should check passed in model type
#257
Comments
Yeah this behaviour checks out looking at internal sanic-ext/sanic_ext/extras/validation/schema.py Lines 41 to 69 in fd85ada
That is, passing a bare python class will not raise error but return the empty dict. |
I think only pydantic, msgspec, attrs and dataclasses are supported We can add a check here sanic-ext/sanic_ext/extras/validation/setup.py Lines 48 to 55 in fd85ada
maybe like + if isclass(param) and not is_attrs(param) and not is_dataclass(param):
+ raise SchemaNotSupported
return make_schema({}, param) if isclass(param) else param |
Describe the bug
The
validate
function should check the type of the passed in schema.In my case doing this:
Fails miserably with:
Inspecting it closer, it turns out
schemas
looks like this:I assume the issue is with
generate_schema
for some reason just returning{}
instead of raising an exceptionTo 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
The text was updated successfully, but these errors were encountered: