繁体   English   中英

django REST swagger函数为基础的api没有输入参数

[英]django REST swagger function based api does not have input PARAMETERS

我正在按照这些说明大胆地做基于Django REST函数的API。

https://github.com/m-haziq/django-rest-swagger-docs

但是,我无法获得函数中显示的任何参数。 这是不显示任何参数的屏幕截图。 https://imgur.com/a/fDITT https://imgur.com/a/n5CDU

更新:这就是我要使用参数https://imgur.com/a/cLYNF实现的方式

这是我的API代码,我想在招摇中显示“名称”参数https://gitlab.com/firdausmah/railercom/blob/master/railercomapp/api.py

@api_view(['POST'])
def test_post(request):
    # ----- YAML below for Swagger -----
    """
    description: This API deletes/uninstalls a device.
    parameters:
      - name: name
        type: string
        required: true
        location: form
    """
    name = request.POST.get('name')

    return Response("Data Saved!", status=status.HTTP_201_CREATED)

这是我的点子冻结库与django-rest-swagger-docs https://gist.github.com/anonymous/c5c328b9e4a6ff3f86676fe930440dd2的工作示例的区别

有什么问题,您可以在gitlab中查看整个源代码。 谢谢。

我在自述文件中找到了这个

*Input parameters for function based views do not appear:* You might be using
    incompatible versions, try using `djangorestframework==3.5.3` and `django-rest-swagger==2.1.1`. 

我更新为djangorestframework == 3.5.3并且它有效

暂无
暂无

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

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