generated from Eddie/Backend-Boilerplate
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
732 B
25 lines
732 B
2 years ago
|
from marshmallow_sqlalchemy import SQLAlchemyAutoSchema
|
||
|
from config import db
|
||
|
from models import User
|
||
|
from marshmallow import fields
|
||
|
|
||
|
#*______________ Base Schema ______________
|
||
|
class BaseScheme(SQLAlchemyAutoSchema):
|
||
|
def __str__(self):
|
||
|
return str(self.__class__) + ": " + str(self.__dict__)
|
||
|
class Meta:
|
||
|
ordered = True
|
||
|
sqla_session = db.session
|
||
|
include_fk = True
|
||
|
load_instance = True
|
||
|
|
||
|
#*______________ User Schemes ______________
|
||
|
class UserSchema(BaseScheme):
|
||
|
class Meta(BaseScheme.Meta):
|
||
|
model = User
|
||
|
id = fields.Int()
|
||
|
name = fields.Str()
|
||
|
class UserInsertSchema(UserSchema):
|
||
|
user_id = fields.Int()
|
||
|
class UserResponseSchema(UserSchema):
|
||
|
name = fields.Str()
|