example.py 857B

12345678910111213141516171819202122232425262728293031323334
  1. # -*- coding: utf-8 -*-
  2. import marshmallow
  3. class ErrorResponseSchema(marshmallow.Schema):
  4. message = marshmallow.fields.String(required=True)
  5. details = marshmallow.fields.Dict(required=True)
  6. class HelloResponseSchema(marshmallow.Schema):
  7. sentence = marshmallow.fields.String(required=True)
  8. name = marshmallow.fields.String(required=True)
  9. color = marshmallow.fields.String(required=False)
  10. class HelloPathSchema(marshmallow.Schema):
  11. name = marshmallow.fields.String(
  12. required=True,
  13. validate=marshmallow.validate.Length(min=3),
  14. )
  15. class HelloQuerySchema(marshmallow.Schema):
  16. alive = marshmallow.fields.Boolean(
  17. required=False,
  18. )
  19. class HelloJsonSchema(marshmallow.Schema):
  20. color =marshmallow.fields.String(
  21. required=True,
  22. validate=marshmallow.validate.Length(min=3),
  23. )