fastapi icon indicating copy to clipboard operation
fastapi copied to clipboard

Integrate with external validators

Open pchanial opened this issue 3 years ago • 3 comments

First check

  • [x] I added a very descriptive title to this issue.
  • [x] I used the GitHub search to find a similar issue and didn't find it.
  • [x] I searched the FastAPI documentation, with the integrated search.
  • [x] I already searched in Google "How to X in FastAPI" and didn't find any information.
  • [x] I already read and followed all the tutorial in the docs and didn't find an answer.
  • [x] I already checked if it is not related to FastAPI but to Pydantic.
  • [x] I already checked if it is not related to FastAPI but to Swagger UI.
  • [x] I already checked if it is not related to FastAPI but to ReDoc.
  • [x] After submitting this, I commit to:
    • Read open issues with questions until I find 2 issues where I can help someone and add a comment to help there.
    • Or, I already hit the "watch" button in this repository to receive notifications and I commit to help at least 2 people that ask questions in the future.
    • Implement a Pull Request for a confirmed bug.

Description

Currently, there is only one package that can be used for validation and (de)-serialization. Having the possibility to choose one's validator library would strenghten the micro-framework part of FastAPI and bolster faster and innovative projects (I'm thinking of apischema, but there could be others). Currently, the approach of having to build another framework such as Flama to simply be able to use another validator does not make sense to me.

The solution you would like

Have an interface in FastAPI for the validation / deser so that external (non-default) validators such as marshmallow, apischema, etc. could be plugged in.

pchanial avatar Jun 11 '21 08:06 pchanial

I would like to contribute on implementing this

hamzabouissi avatar Jun 30 '21 18:06 hamzabouissi

We would be very interested in this as we use apischema a lot. @tiangolo does this align with your goals for FastAPI? Would you accept a PR adding a plugin mechanism for external validators?

coretl avatar Aug 02 '22 09:08 coretl

We would also be interested in this, especially the ability to integrate with apischema.

c00kiemon5ter avatar Aug 04 '22 16:08 c00kiemon5ter

My own performance testing between typedload, apischema and pydantic looks like this: https://ltworf.github.io/typedload/performance.html

ltworf avatar Aug 23 '22 05:08 ltworf