简体   繁体   English

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

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

I am trying to do Django REST function based API with swagger following these instructions. 我正在按照这些说明大胆地做基于Django REST函数的API。

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

However, I am unable to get any parameters shown in the function. 但是,我无法获得函数中显示的任何参数。 This is the screenshot of swagger NOT displaying any parameters. 这是不显示任何参数的屏幕截图。 https://imgur.com/a/fDITT https://imgur.com/a/n5CDU https://imgur.com/a/fDITT https://imgur.com/a/n5CDU

UPDATE:This is how I want to achieve with the parameters https://imgur.com/a/cLYNF 更新:这就是我要使用参数https://imgur.com/a/cLYNF实现的方式

Here is my API code, I want to have "name" parameters shown in swagger https://gitlab.com/firdausmah/railercom/blob/master/railercomapp/api.py 这是我的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)

This is the difference on my pip freeze library with the working example of django-rest-swagger-docs https://gist.github.com/anonymous/c5c328b9e4a6ff3f86676fe930440dd2 这是我的点子冻结库与django-rest-swagger-docs https://gist.github.com/anonymous/c5c328b9e4a6ff3f86676fe930440dd2的工作示例的区别

What is the problem, you can view the whole source code in gitlab. 有什么问题,您可以在gitlab中查看整个源代码。 Thanks. 谢谢。

I found this in readme 我在自述文件中找到了这个

*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`. 

I updated to djangorestframework==3.5.3 and it works 我更新为djangorestframework == 3.5.3并且它有效

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

相关问题 基于Django rest函数的api中的Swagger在ubuntu服务器上无法正确显示(生产) - Swagger in Django rest function based api does not show properly on ubuntu server (production) Django REST Swagger如何处理响应POST api(基于函数) - Django REST Swagger how to process response POST api (function based) Django Rest Swagger 2:到目前为止,是否有记录基于 FUNCTION 视图的 POST 请求的参数? - Django Rest Swagger 2: Is there anyway so far to document parameters for POST requests of FUNCTION based views? django-rest-swagger UI 没有 POST 请求正文的表单(基于函数的视图) - django-rest-swagger UI doesn't have form for POST request body (function based view) Django Rest Framework:如何为基于函数的视图启用 swagger 文档 - Django Rest Framework: How to enable swagger docs for function based views 如何在 Django REST Swagger 2 中记录参数? - How to document parameters in Django REST Swagger 2? Django Rest Framework:基于函数的API序列化器 - Django Rest Framework: Function Based API serializers 如何在Django Rest招摇中隐藏一些API? - How to hide Some API in django rest swagger? django-rest-framework和swagger api文档 - django-rest-framework and swagger api documentation Django rest framework Api文档Swagger 2.0 - Django rest framework Api documentation Swagger 2.0
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM