繁体   English   中英

drf-yasg:如何更改 operationId?

[英]drf-yasg: How to change operationId?

在此处输入图像描述

使用 drf-yasg 时如何更改 redoc-ui 中自动出现的请求的名称。

例如:在图像中,您可以看到请求名为 fid_data-entities_update,它是从 URL 中提取的。

如何覆盖/重命名它?

您可以使用@swagger_auto_schema(...)装饰器来覆盖operationId规范,就像使用operation_id参数一样

from rest_framework import generics
from rest_framework.response import Response
from drf_yasg.utils import swagger_auto_schema


class OperationIdOverrideAPI(generics.ListAPIView):

    @swagger_auto_schema(operation_id="Your awesome name")
    def get(self, request, *args, **kwargs):
        return Response({"message": "ok"})

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM