marshmallow-code / marshmallow-code/flask-smorest
Dynamic serialization schema
- Dominant language
- Python
- Stars
- 717
- Forks
- 77
- Avg merge
- 7h 49m
- Merged PRs (30d)
- 3
Description
It would be useful to reimplement the `ResponseMixin.response` function to accept a static function as the _schema_ argument so that we can build the schema based on the client request, which is needed for _JSON:API_ requests and using _marshmallow-jsonapi_ as a serializer.
Below is an example of a use case:
```python3
@bp.route('/')
class Resource(MethodView)
def get_fields(request):
fields = parser.parse(JsonApiRequestSchema, request, location='query')
schema = ResourceSchema(many=true, only=fields)
return schema
@bp.response(200, get_fields)
def get(self):
pass
```
Contributor guide
Research direction
Start by reading the ResponseMixin.response function and compare its current schema handling with the example using get_fields. Trace how the client request reaches response serialization. Done means a static function can build and supply the schema for JSON:API and marshmallow-jsonapi use cases, with behavior covered by the project's existing checks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- flask, python
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100