I have installed drf-yasg, and it's working great. The problem I've got is that it's a big app, and has a huge amount of endpoints for each type of frontend client, i.e. /admin/v1, /app/v1, ...
So I thought it would be a good idea to separate documentation for each type, i.e
urlpatterns += [
url(r'^/admin/swagger/$', admin_schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
url(r'^/app/swagger/$', app_schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
]
So it looks as though drf-yasg supports this, via supplying patterns into the get_scheme_view:
admin_schema_view = get_schema_view(
openapi.Info(
title="API",
default_version='v1',
description="The set of API endpoints used.",
terms_of_service="https://www.google.com/policies/terms/",
contact=openapi.Contact(email="contact@me"),
license=openapi.License(name="BSD License"),
),
patterns=?????,
validators=['flex', 'ssv'],
public=True,
permission_classes=(permissions.AllowAny,),
)
Now my guess was to supply a string, the same way as the first string when defining urls, such as patterns=r'^admin/v1/', which results in:
File "/usr/local/lib/python3.6/dist- packages/rest_framework/compat.py", line 55, in get_original_route
return urlpattern.regex.pattern
AttributeError: 'str' object has no attribute 'regex'
So with the documentation at drf-yasg docs:
patterns – if given, only these patterns will be enumerated for inclusion in the API spec
Exactly what type of object is needed here in order for to process patterns? I've tried looking around the django-rest-framework and Django source code on github, but couldn't find what type is actually needed, they are both very large projects.