Created
January 1, 2022 00:08
-
-
Save smaillns/c4f63477a0ebbe35d08ed947fb2863cf to your computer and use it in GitHub Desktop.
Marshmallow schemas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from marshmallow import Schema, fields | |
class AuthorSchema(Schema): | |
id = fields.Int(required=True) | |
name = fields.Str(required=True) | |
gender = fields.Str(required=True) | |
created_at = fields.Date() | |
updated_at = fields.Date() | |
class BookSchema(Schema): | |
id = fields.Int(required=True) | |
created_at = fields.Date() | |
updated_at = fields.Date() | |
title = fields.Str(required=True) | |
author = fields.Nested(AuthorSchema, many=False) | |
class CreateBookSchema(Schema): | |
title = fields.Str(default=None) | |
author_id = fields.Int(required=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment