marshmallow-code / flask-marshmallow

Flask + marshmallow for beautiful APIs
http://flask-marshmallow.readthedocs.io/
MIT License
875 stars 59 forks source link

Should I use flask-marshmallow with flask-smorest and marshmallow-sqlalchemy? #337

Closed abceleung closed 1 month ago

abceleung commented 1 month ago

Hi, I have a Flask application with Flask-SQLAlchemy. I am confused by the relationship between the official plugins.

I see that both flask-marshmallow and marshmallow-sqlalchemy offers SQLAlchemyAutoSchemaOpts, SQLAlchemySchema and SQLAlchemySchemaOpts. These two libraries seems to be mostly overlapping in features. If I am using Flask-SQLAlchemy, I should use flask-marshmallow instead of marshmallow-sqlalchemy, correct?

Also, I use flask-smorest for the automated OpenAPI spec generation. Do flask-smorest and flask-marshmallow work well together? Thanks.

abceleung commented 1 month ago

Answering one of my own question: Turns out you need to install marshmallow-sqlalchemy and flask-marshmallow together, otherwise auto_field will be missing.

sloria commented 1 month ago

That's right; marshmallow-sqlalchemy is an optional dep to flask-marshmallow, so you need to explicitly install it.

As far as using flask-marshmallow with flask-smorest: go for it! They occupy different areas of responsibility (flask-marshmallow for schema definition, flask-smorest for the view layer).