bauerji / flask-pydantic

flask extension for integration with the awesome pydantic package
MIT License
368 stars 58 forks source link

How can I give custom params for Request.get_json(force=False, silent=False, cache=True) ? #37

Closed gwind closed 3 years ago

gwind commented 3 years ago

I saw that get_json() method have no any params in line: https://github.com/bauerji/flask_pydantic/blob/45987a2d4474b5c9423e057a66d98863468fa0bd/flask_pydantic/core.py#L176

but the flask support some custom params, in doc: https://tedboy.github.io/flask/generated/generated/flask.Request.get_json.html

Currently, there was some errors when a post request have no request body:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">\n<title>400 Bad Request</title>\n<h1>Bad Request</h1>\n<p>Failed to decode JSON object: Expecting value: line 1 column 1 (char 0)</p><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">\n<title>400 Bad Request</title>\n<h1>Bad Request</h1>\n<p>Failed to decode JSON object: Expecting value: line 1 column 1 (char 0)</p>
bauerji commented 3 years ago

Hi @gwind, Thank you for pointing out. Now there is an option to specify these params in validate's get_json_params parameter. It's included in the new version 0.9.0.