Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Pydantic #234

Open
miquelvir opened this issue May 29, 2021 · 3 comments
Open

Support for Pydantic #234

miquelvir opened this issue May 29, 2021 · 3 comments

Comments

@miquelvir
Copy link

This seems a solid foundation. It would be awesome if you added support for using Pydantic schemas and/or using Typing annotations. Starting stone here (https://github.com/bauerji/flask_pydantic). Is this something you would be interested in?

@RookieRick
Copy link
Contributor

👋 There has been some discussion/interest around adding support for Pydantic. Will have a look at flask_pydantic - would be awesome if we can leverage what they've already built without reinventing the wheel and I see there's discussion over there around adding OpenAPI generation (bauerji/flask-pydantic#17) so potentially a nice win-win for both projects!

@barakalon
Copy link
Contributor

Personally, I don't think flask-rebar should aim to support Pydantic. I think this would be trying to do too many things.

Flask-rebar is mostly a little glue between the real heavy-lifters: Flask, Marshmallow, and OpenAPI. If you remove this glue, I'm not sure how much code is actually left in Flask-rebar.

In other words, the majority of code in Flask-rebar is a specific to Marshmallow - Marshmallow validation/marshaling integration, conversion between Marshmallow schemas and OpenAPI, etc.
If we add support for Pydantic, I feel like we might as well write an entirely new package.

Instead, I think we should aim for better support for type annotations. Flask-rebar was written several years ago and was intended to support Python 2. As Python 2 itself is no longer supported and type annotations are becoming standard, I think we can give Flask-rebar a typing facelift.

When it comes to typed request/response objects, perhaps we should stick with something based on Marshmallow. There are some existing packages out there:

But both of those are pretty small, so it could also make sense to roll our own instead of taking on an additional dependency.

tldr:
❌ Pydantic support
✅ Type annotations

@dekim24
Copy link
Contributor

dekim24 commented Apr 8, 2022

I'm actually planning to add type annotations (+ mypy support?) as my next ADSK hack week project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants