New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use python 3.7 new dataclass to specify Schema #204

Open
jorgeCollinet opened this Issue Jun 28, 2018 · 0 comments

Comments

Projects
None yet
2 participants
@jorgeCollinet

jorgeCollinet commented Jun 28, 2018

With the new python 3.7 dataclass (https://www.python.org/dev/peps/pep-0557/)

It would be nice to automatically infer the response schema from it , instead of:

from marshmallow import Schema, fields, post_load
from flasgger import Swagger, SwaggerView

class FooSchema(Schema):
    url = fields.Str(required=True)

class FooView(SwaggerView):
    responses = {
        200: {
            'description': 'Foo Example',
            'schema': FooSchema
        }
    }
    . . . . 

do

from flasgger import Swagger, SwaggerView

@dataclass
class Foo:
    url: str

class FooView(SwaggerView):
    responses = {
        200: {
            'description': 'Foo Example',
            'schema': Foo
        }
    }
    . . . . 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment