Infer schema from declared SQLAlchemy models #42
Replies: 1 comment
-
I've thought about this quite a bit actually. You could have the views automatically create a default schema using marshmallow-sqlalchemy's SQLAlchemyAutoSchema. I've used this object and marshmallow/sqlalchemy a lot in production. The reality is that I have never actually been able to use the autogenerated schemas without some kind of one-off configuration though. That's the biggest reason I haven't added support yet. That being said I'm coming at this from the experience of incorporating this pattern into large legacy codebases. In side projects, small services or weekend hackathon projects it might be completely viable to use the auto-generated schemas. If you've got a need for it personally I'm happy to put it in backlog and implement. I think it should be relatively quick to add (famous last words). Or if you're looking to contribute I'm always open to help. |
Beta Was this translation helpful? Give feedback.
-
Would it be possible to infer the schema directly from the already declared models without having to write them in marshmallow or Pydantic?
I took only cursory look through the source code, but I'd be interested in exploring it further. It looks like most of the work would be in building (or finding) a
serializer
for SQLAlchemy models. If there's no requirement for an extra schema it would really expand the number of projects Flask-Muck could be useful to!Beta Was this translation helpful? Give feedback.
All reactions