【发布时间】:2020-04-15 13:10:47
【问题描述】:
我正在尝试在 Django REST 框架中为我的 REST API 定义 AutoSchema(将在 django REST 框架 swagger 中显示)。有这个类扩展了 APIView。
该类同时具有“get”和“post”方法。喜欢:
class Profile(APIView):
permission_classes = (permissions.AllowAny,)
schema = AutoSchema(
manual_fields=[
coreapi.Field("username",
required=True,
location='query',
description='Username of the user'),
]
)
def get(self, request):
return
schema = AutoSchema(
manual_fields=[
coreapi.Field("username",
required=True,
location='form',
description='Username of the user '),
coreapi.Field("bio",
required=True,
location='form',
description='Bio of the user'),
]
)
def post(self, request):
return
问题是我想要获取和发布请求的不同架构。如何使用 AutoSchema 实现这一点?
【问题讨论】:
-
请阅读Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers? - 总结是这不是解决志愿者的理想方式,并且可能会适得其反。请不要将此添加到您的问题中。
标签: python django django-rest-framework django-rest-swagger