Open puittenbroek opened 4 days ago
In my opinion, the _validate_query should simply let the pydantic model do the validation.
This works until you need to do arrays, or complex parameters style
defined in Openapi.
It would be great if this type of parsing was moved elsewhere though (like in pydantic?)
There should be a general library that parses form, query, path, headers for openapi3 different style
parameters.
Have to be looked how other frameworks do it like fastapi or litestar.
We currently also use
flask_pydantic
since that was our first step into getting pydantic incorporated into flask.It's
validate
function uses the pydantic model for the query as-is to check the incoming query parameters. ViaIn our project we do the following:
While using
flask_pydantic
'svalidate
; passing any unknown fields will cause a ValidationError, which is very desirable for many.But in flask-openapi3 the
_validate_query
pre-processes in the incoming data and does all sort of things. But effectively filters out any unknown query parameters, which prevents the validation error.In my opinion, the
_validate_query
should simply let the pydantic model do the validation. Similar to the_validate_path
.The function seems overly complex. Just do this: