schema.py 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # -*- coding: utf-8 -*-
  2. import marshmallow
  3. class NoContentSchema(marshmallow.Schema):
  4. pass
  5. class AboutSchema(marshmallow.Schema):
  6. """ Representation of the /about route """
  7. version = marshmallow.fields.String(required=True)
  8. datetime = marshmallow.fields.DateTime(required=True)
  9. class UserIdPathSchema(marshmallow.Schema):
  10. """
  11. representation of a user id in the uri. This allow to define rules for
  12. what is expected. For example, you may want to limit id to number between
  13. 1 and 999
  14. """
  15. id = marshmallow.fields.Int(
  16. required=True,
  17. validate=marshmallow.validate.Range(min=1),
  18. )
  19. class UserSchema(marshmallow.Schema):
  20. """Complete representation of a user"""
  21. id = marshmallow.fields.Int(required=True)
  22. first_name = marshmallow.fields.String(required=True)
  23. last_name = marshmallow.fields.String(required=True)
  24. email_address = marshmallow.fields.Email(required=True)
  25. display_name = marshmallow.fields.String(required=False)
  26. company = marshmallow.fields.String(required=False)
  27. class UserDigestSchema(marshmallow.Schema):
  28. """User representation for listing"""
  29. id = marshmallow.fields.Int(required=True)
  30. display_name = marshmallow.fields.String(required=False, default='')