lovasoa / marshmallow_dataclass

Automatic generation of marshmallow schemas from dataclasses.
https://lovasoa.github.io/marshmallow_dataclass/html/marshmallow_dataclass.html
MIT License
458 stars 78 forks source link

Use Schema for marshal_with #215

Closed igoncharov85 closed 1 year ago

igoncharov85 commented 2 years ago

Can the Schema generated from dataclass be used for flask-restx response serialization? marshal_with

ModelSchema = marshmallow_dataclass.class_schema(ViewModel)()

class SomeResource(Resource): @api.marshal_with(ModelSchema) def get(self): return result # no need to write ModelSchema.dump(result)

dairiki commented 1 year ago

I am not particularly familiar with flask-restx, so take my answer with a grain of salt.

From a quick look at the flask-restx docs, it does not appear than marshal_with is expecting a Marshmallow schema as an argument. If that's correct, then I doubt it will work without some adaptation.

Closing, as this isn't a issue.