小编Nav*_*wal的帖子

当我点击 /swagger url 时出现“AssertionError:duplicate Parameters found”

我正在我的项目中使用drf-yasg为 django rest 框架 API实现 swagger 。

我遵循 drf-yasg 的快速入门部分。当我点击 /swagger 时,得到 AssertionError:发现重复参数。下面是我的代码和回溯。

网址.py

from drf_yasg.views import get_schema_view
from drf_yasg import openapi

schema_view = get_schema_view(
   openapi.Info(
      title="Snippets API",
      default_version='v1',
      description="Test description",
      terms_of_service="https://www.google.com/policies/terms/",
      contact=openapi.Contact(email="contact@snippets.local"),
      license=openapi.License(name="BSD License"),
   ),
   public=True,
   permission_classes=(permissions.AllowAny,),
)

urlpatterns = [
    url(r'^swagger(?P<format>\.json|\.yaml)$', schema_view.without_ui(cache_timeout=0), name='schema-json'),
    url(r'^swagger/$', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
    url(r'^redoc/$', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
    # path('graphql', csrf_exempt(GraphQLObservableUnboxingView.as_view(graphiql=True, schema=schema))),
]
Run Code Online (Sandbox Code Playgroud)

追溯


```Traceback (most recent call last):
  File "/home/abc/development/sw_api/env_sw_api_python3.7/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/home/abc/development/sw_api/env_sw_api_python3.7/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in …
Run Code Online (Sandbox Code Playgroud)

django swagger django-rest-framework drf-yasg

6
推荐指数
1
解决办法
608
查看次数

标签 统计

django ×1

django-rest-framework ×1

drf-yasg ×1

swagger ×1