APIFairy icon indicating copy to clipboard operation
APIFairy copied to clipboard

Schema for output not working

Open guilhermecfmello opened this issue 11 months ago • 3 comments

Hello! Is there any bug found on APIFairy response decorator? I'm trying to define a simple schema for the response but it looks like flask tries to serialize the object instead of letting it to APIFairy lib:

image

guilhermecfmello avatar Dec 10 '24 20:12 guilhermecfmello

The argument to the response decorator is a marshmallow schema. It looks like you are passing the class of an object you want to return instead.

miguelgrinberg avatar Dec 10 '24 22:12 miguelgrinberg

Hi Miguel! Thanks in advance for your answer.

In this case Ping is a marshmallow schema, since it's inheriting the 'marshmallow.Schema' class.

I'm doing the same for the @body decorator and it's working to serialize the input.image

guilhermecfmello avatar Dec 11 '24 13:12 guilhermecfmello

Try using the Schema class from the Flask-Marshmallow extension. See the examples in this repository for guidance.

miguelgrinberg avatar Dec 11 '24 15:12 miguelgrinberg