如何在基于类的 django 视图中自定义 drf-yasg 模式?
我尝试了这部分代码,但生成的招摇不尊重更改。
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')
...