viewUser.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  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. operation_description="apiview post description override",
  10. request_body=openapi.Schema(
  11. type=openapi.TYPE_OBJECT,
  12. required=['page', 'pageSize'],
  13. properties={
  14. 'page': openapi.Schema(type=openapi.TYPE_NUMBER),
  15. 'pageSize': openapi.Schema(type=openapi.TYPE_NUMBER),
  16. },
  17. ),
  18. security=[], tags=tags, operation_summary='列表')
  19. def list(self, request):
  20. print('debug')
  21. msg=''
  22. try:
  23. # print("post_post",request.POST)
  24. print("post_body",request.body)
  25. msg='Hello! Users. body : %s' % (request.body)
  26. except(RuntimeError, TypeError, NameError) as e:
  27. print(e)
  28. msg='Hello! Users. exception'
  29. return HttpResponse(msg)
  30. # pass