简体   繁体   English

drf-yasg 如何在外面显示 api 描述?

[英]drf-yasg how to display the api description outside?

I want the describe in there:我想要那里的描述:
图片1
but mine is in there:但我的在那里:
图 2
This is my code:这是我的代码:

@swagger_auto_schema(method='GET', manual_parameters=[project_param])
@api_view(['GET'])
def get_project_info(request):
    """
    获取项目信息
    """

Version info:版本信息:
Django==2.2.1 Django==2.2.1
drf-yasg==1.16.1 drf-yasg==1.16.1

if Docstring used in below format description will be available in there:如果在以下格式描述中使用的 Docstring 将在那里可用:

class ProductOperation(ModelViewSet):
   """
   Outside

   Inside

   """

在此处输入图像描述

you can use swagger_auto_schema decorator to display id, summary and description.您可以使用swagger_auto_schema装饰器来显示 id、摘要和描述。

from drf_yasg.utils import swagger_auto_schema

class ProductOperation(ModelViewSet):
    @swagger_auto_schema(
        operation_id='Display end of opblock',
        operation_summary="Display outside",
        operation_description='Display inside',
    )
    def action_one(self, request):
        dosomething()

looks like this看起来像这样

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

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