【发布时间】:2020-07-24 07:09:39
【问题描述】:
如何在 ClassBased django 视图中自定义 drf-yasg 架构?
我尝试了这部分代码,但生成的 swagger 不尊重更改。
class CustomView(CreateAPIView):
permission_classes = (IsAuthenticated,)
serializer_class = CustomSerializer
@swagger_auto_schema(request_body=openapi.Schema(
type=openapi.TYPE_OBJECT,
properties={
'phone': openapi.Schema(type=openapi.TYPE_STRING, description='string'),
'body': openapi.Schema(type=openapi.TYPE_STRING, description='string'),
}))
def create(self, request: Request, *args, **kwargs):
phone = request.data.get('phone')
body = request.data.get('body')
...
【问题讨论】: