Django Rest框架模式vi

2024-06-10 04:15:43 发布

您现在位置:Python中文网/ 问答频道 /正文

我按照教程使用SchemaView生成一个动态模式

https://www.django-rest-framework.org/api-guide/schemas/#generating-a-dynamic-schema-with-schemaview

在我的主要urls.py中,我做:

apiv1_urlpatterns = [
    url(r'^company/', include('app.company.api_v1.urls', namespace='company')),
    url(r'^geographic/', include('app.geographic.api_v1.urls', namespace='geographic'))
]


urlpatterns += [
    url(r'^api/v1/', include(apiv1_urlpatterns, namespace='api_v1')),
]

schema_v3_view = get_schema_view(
    title='MY API Verson 3',
    url='https://www.example.org/api/',
    patterns=apiv1_urlpatterns
)

urlpatterns += [
    url(r'^open-api/v1/', schema_v1_view, name='openapi-v1-schema'),
]

这就是我所看到的:

enter image description here

如果删除patterns参数,则得到:


{
    "detail": "You do not have permission to perform this action."
}

Tags: httpsorgviewapiurlincludeschemawww