Redirect top-level API view

This commit is contained in:
shamoon 2024-12-10 09:29:57 -08:00
parent 38e45efdcf
commit ef4198e043
2 changed files with 6 additions and 2 deletions

View File

@ -88,14 +88,14 @@ class TestApiAuth(DirectoriesMixin, APITestCase):
)
def test_api_version_no_auth(self):
response = self.client.get("/api/")
response = self.client.get("/api/documents/")
self.assertNotIn("X-Api-Version", response)
self.assertNotIn("X-Version", response)
def test_api_version_with_auth(self):
user = User.objects.create_superuser(username="test")
self.client.force_authenticate(user)
response = self.client.get("/api/")
response = self.client.get("/api/documents/")
self.assertIn("X-Api-Version", response)
self.assertIn("X-Version", response)

View File

@ -222,6 +222,10 @@ urlpatterns = [
],
),
),
re_path(
"^$", # Redirect to the API swagger view
RedirectView.as_view(url="schema/view/"),
),
*api_router.urls,
],
),