jmcarp / jmcarp/flask-apispec

Class-level settings API

Open
#2 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
652
Forks
151
PR merge metrics
No merged PRs in 30d

Description

(How) should users use a given schema or args dictionary for all view methods in a class?

One proposal, based on the `decorators` class variable already used in Flask (although we'd probably have to modify the implementation of `decorators` to get this to work as expected with inheritance):

``` python
class Resource:
decorators = [
marshal_with(PetSchema),
use_kwargs(pet_args),
]
def get(self):
"""Serialized with PetSchema"""
pass
def put(self):
"""Serialized with PetSchema"""
pass
```

Or, for future compatibility with other frameworks, we can extend the existing decorators to handle classes:

``` python
@marshal_with(PetSchema)
class Resource:
def get(self):
"""Serialized with PetSchema"""
pass
def put(self):
"""Serialized with PetSchema"""
pass
```

Ping @sloria.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.