Should/can schema coerce datatype?
proximous opened this issue · 1 comments
proximous commented
Is it possible to use a schema to coerce a datatype with querystring_schema or match_info_schema?
For example:
class MyBool(Schema):
mybool = fields.Boolean()
@querystring_schema(MyBool)
async def my_func(request: web.Request):
mybool = request.query.getone('mybool')
dtype = type(mybool) # this will be a string not a bool`
example call:
curl http://localhost:8080/my_func_url?mybool=true
Should/can the schema coerce 'mybool' to a type bool? Ideally the schema would coerce the datatype rather than me having to do so within my function.
proximous commented
Figured out I was using the wrong dereference and should have been using:
mybool = request["querystring"]