Closed jsnyder10 closed 1 year ago
If you don't want to have pagination information, then you shouldn't use the paginated decorator. Create a schema for the payload that you want to return, put it in the @response
decorator, and then make sure your endpoint returns data that is compatible with that schema.
Thanks for the answer Miguel. I don't know why all my dictionaries are turned into empty dictionaries when passing through the wrappers.
Here is a route I made that uses @response, but when it passes to the browser I get {}
@types.route('/types3', methods=['GET']) @authenticate(token_auth) @response(type_schema2) def get(): """Return all types""" types = db.session.scalars(Type.select()).all() print(types) return types
I did the print to show my dicitonary query formatted properly before it got to the return. Here is what the console shows from my print statement: [<Type 1>, <Type 2>, <Type 3>, <Type 4>, <Type 5>, <Type 6>, <Type 7>, <Type 8>]
Got any ideas?
I dug through the docs and never found the answer. After compiling someone else's example I found I just needed to put many=True inside my TypeSchema at the top of my routes type_schema = TypeSchema(many=True).
I really appreciate all the tutorials you've made. I've gone through your flask mega tutorial and I bought your react mega tutorial. You've been a big help on my programming journey.
Hi Miguel. Thanks for open sourcing the microblog-api project. By any chance do you have a tutorial for it? If not I am trying to get rid of the "data" entry along with the object format on top. I can't figure out how to do this. Do you have any suggestions?
Format wanted:
Using the paginated decorator you made I get this: