example.py 953B

1234567891011121314151617181920212223242526272829303132333435363738
  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. )
  24. class HelloFileSchema(marshmallow.Schema):
  25. myfile = marshmallow.fields.Raw(required=True)