为什么不使用 drf-yasg 文档。我只看到默认设置。
api_patterns = [
url(r'^api/v1/users/', include('apps.users.urls')),
]
schema_view = get_schema_view(
openapi.Info("PlasticJam", 'v1'),
patterns=api_patterns,
public=True,
)
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'),
]
意见
@method_decorator(swagger_auto_schema(
manual_parameters=[openapi.Parameter(
name='users_count', in_=openapi.IN_QUERY, type='int', description='Count of users'
)],
responses={'200': 'ok'}), name='list'
)
class UserListApiView(ListAPIView):
"""
list:
Users detail statistic
Get dates range for statistic
"""
queryset = User.objects.all()
serializer_class = UserListSerializer