Skip to content

Commit aab16fd

Browse files
committed
Add OpenAPI and Swagger-UI URLs to v1 API
1 parent 594d345 commit aab16fd

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

python/nav/web/api/v1/urls.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
# pylint: disable=E1101
1818
"""Urlconf for the NAV REST api"""
1919

20-
from django.urls import re_path, include
20+
from django.urls import path, re_path, include
21+
from drf_spectacular.views import SpectacularAPIView, SpectacularSwaggerView
2122
from rest_framework import routers
2223

2324
from nav.auditlog import api as auditlogapi
@@ -54,8 +55,17 @@
5455
router.register(r'auditlog', auditlogapi.LogEntryViewSet, basename='auditlog')
5556
router.register(r'module', views.ModuleViewSet, basename='module')
5657

58+
openapi_urls = [
59+
path('', SpectacularAPIView.as_view(api_version="1"), name='schema'),
60+
path(
61+
"swagger-ui/",
62+
SpectacularSwaggerView.as_view(url_name="api:1:openapi:schema"),
63+
name="swagger-ui",
64+
),
65+
]
5766

5867
urlpatterns = [
68+
path("schema/", include((openapi_urls, "openapi"))),
5969
re_path(r'^$', views.api_root),
6070
re_path(r'^token/$', views.get_or_create_token, name="token"),
6171
re_path(r'^version/$', views.get_nav_version, name="version"),

0 commit comments

Comments
 (0)