Use Schema for marshal_with
igoncharov85 opened this issue · comments
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)
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.