List of objects does not serialize properly after flask upgrade from 1.0.3 to 1.1
- Dominant language
- Python
- Stars
- 652
- Forks
- 151
- PR merge metrics
- No merged PRs in 30d
Description
After changing to from version 1.0.3 to 1.1 my marshall with many code breaks. @ThiefMaster from the flask development team surgested transfering the issue to you. See https://github.com/pallets/flask/issues/3348
```python
from marshmallow import fields
from flask import Blueprint
from flask_apispec import marshal_with, doc
from database import Team
from marshmallow import Schema
bp = Blueprint("team", __name__, url_prefix="/teams")
class TeamSchema(Schema):
id = fields.Str(required=True, dump_only=True, example="1")
name = fields.Str(required=True, example="123 Abc")
@bp.route("")
@marshal_with(TeamSchema(many=True), description="A list of teams.")
@doc(tags=["Team"])
def search():
"""Fetch the list of teams, ordered by name."""
return Team.query.order_by("name")
```
And gives the following error when invoked either by localhost/teams
`TypeError: The view function did not return a valid response. The return type must be a string, dict, tuple, Response instance, or WSGI callable, but it was a list.`
When running when changing to flask 1.0.3 it works. Without an error
### Environment
* Python version: 3.6.8
* Flask version: 1.1
* Werkzeug version: 0.15.5
* marshmallow: 2.20.2
* flask-apispec: 2.0.2
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the example /teams route with Python 3.6.8, Flask 1.1, marshmallow 2.20.2, and flask-apispec 2.0.2, then compare its behavior with Flask 1.0.3. Trace the marshal_with response path; done means a many=True result is converted into a valid Flask response without requiring the application to downgrade Flask.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- flask, python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100