Calling the API with query params ex: ?q=12345
will raise 400 error. without query params is fine
Here’s the sample code
from dataclasses import dataclass, asdict
from typing import Optional
from sanic import Sanic
from sanic.response import json
from sanic_ext import validate
app = Sanic("Sanic-APP")
@dataclass
class SearchParams:
q: Optional[str] = None
@app.route("/")
@validate(query=SearchParams)
async def handler(request, query: SearchParams):
return json(asdict(query))
Sanic version 22.6.0
Sanic-ext version 22.6.1