viewUser.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. # -*- coding: utf-8 -*-
  2. from drf_yasg import openapi
  3. from drf_yasg.utils import swagger_auto_schema
  4. from rest_framework.viewsets import ViewSet
  5. from django.http import HttpResponse
  6. tags = ['user']
  7. class User(ViewSet):
  8. @swagger_auto_schema(
  9. tags=['Demo'],
  10. operation_description="apiview post description override",
  11. request_body=openapi.Schema(
  12. type=openapi.TYPE_OBJECT,
  13. required=['page', 'pageSize'],
  14. properties={
  15. 'page': openapi.Schema(type=openapi.TYPE_NUMBER),
  16. 'pageSize': openapi.Schema(type=openapi.TYPE_NUMBER),
  17. },
  18. ),
  19. security=[], tags=tags, operation_summary='列表')
  20. def list(self, request):
  21. print('debug')
  22. msg=''
  23. try:
  24. # print("post_post",request.POST)
  25. print("post_body",request.body)
  26. msg='Hello! Users. body : %s' % (request.body)
  27. except(RuntimeError, TypeError, NameError) as e:
  28. print(e)
  29. msg='Hello! Users. exception'
  30. return HttpResponse(msg)
  31. # pass