|
23 | 23 |
|
24 | 24 | from django.contrib import admin |
25 | 25 | from django.urls import include, path |
| 26 | +from drf_spectacular.views import SpectacularAPIView, SpectacularSwaggerView |
26 | 27 | from rest_framework import permissions |
27 | | -from drf_yasg.views import get_schema_view |
28 | | -from drf_yasg import openapi |
29 | 28 | from rest_framework.routers import DefaultRouter |
30 | 29 |
|
| 30 | + |
31 | 31 | from vulnerabilities.api import PackageViewSet |
32 | 32 | from vulnerabilities.api import VulnerabilityViewSet |
33 | 33 | from vulnerabilities.views import HomePage |
|
41 | 41 | from vulnerabilities.views import VulnerabilityCreate |
42 | 42 | from vulnerabilities.views import VulnerabilityReferenceCreate |
43 | 43 |
|
44 | | -schema_view = get_schema_view( |
45 | | - openapi.Info(title="VulnerableCode API", default_version="v1"), |
46 | | - public=True, |
47 | | - permission_classes=(permissions.AllowAny,), |
48 | | -) |
49 | | - |
50 | 44 | api_router = DefaultRouter() |
51 | 45 | api_router.register(r"packages", PackageViewSet) |
52 | 46 | # `DefaultRouter` requires `basename` when registering viewsets which don't |
|
56 | 50 |
|
57 | 51 | urlpatterns = [ |
58 | 52 | path("admin/", admin.site.urls), |
| 53 | + path('api/schema/', SpectacularAPIView.as_view(), name='schema'), |
| 54 | + path('api/schema/swagger-ui/', SpectacularSwaggerView.as_view(), name='swagger-ui'), |
59 | 55 | path("packages/search", PackageSearchView.as_view(), name="package_search"), |
60 | 56 | path("packages/<int:pk>", PackageUpdate.as_view(), name="package_view"), |
61 | 57 | path("vulnerabilities/<int:pk>", VulnerabilityDetails.as_view(), name="vulnerability_view"), |
|
88 | 84 | name="vulnerability_reference_create", |
89 | 85 | ), |
90 | 86 | path("", HomePage.as_view(), name="home"), |
91 | | - path(r"api/", include(api_router.urls)), |
92 | | - path(r"api/docs", schema_view.with_ui("swagger", cache_timeout=0), name="schema-swagger-ui"), |
| 87 | + path(r"api/", include(api_router.urls)) |
93 | 88 | ] |
0 commit comments