feat(api): don't use trailing slashes (#1982)

This commit is contained in:
Jonas L 2022-07-22 17:34:09 +02:00 committed by GitHub
parent 368350b269
commit f08af1f3fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 85 additions and 85 deletions

View file

@ -13,7 +13,7 @@ from .views import (
VersionView,
)
router = routers.DefaultRouter()
router = routers.DefaultRouter(trailing_slash=False)
router.register("login-attempts", LoginAttemptViewSet)
router.register("preferences", PreferenceViewSet)
router.register("service-registers", ServiceRegisterViewSet)
@ -25,5 +25,5 @@ router.register("third-party-track-references", ThirdPartyTrackReferenceViewSet)
urls = [
*router.urls,
path("version/", VersionView.as_view()),
path("version", VersionView.as_view()),
]

View file

@ -11,7 +11,7 @@ from .views import (
TimestampViewSet,
)
router = routers.DefaultRouter()
router = routers.DefaultRouter(trailing_slash=False)
router.register("listener-counts", ListenerCountViewSet)
router.register("live-logs", LiveLogViewSet)
router.register("mount-names", MountNameViewSet)

View file

@ -7,7 +7,7 @@ from .views import (
StationPodcastViewSet,
)
router = routers.DefaultRouter()
router = routers.DefaultRouter(trailing_slash=False)
router.register("podcast-episodes", PodcastEpisodeViewSet)
router.register("podcasts", PodcastViewSet)
router.register("station-podcasts", StationPodcastViewSet)

View file

@ -16,7 +16,7 @@ from .views import (
WebstreamViewSet,
)
router = routers.DefaultRouter()
router = routers.DefaultRouter(trailing_slash=False)
router.register("playlist-contents", PlaylistContentViewSet)
router.register("playlists", PlaylistViewSet)
router.register("schedule", ScheduleViewSet)

View file

@ -11,7 +11,7 @@ from ...._fixtures import AUDIO_FILENAME
class TestScheduleViewSet(APITestCase):
@classmethod
def setUpTestData(cls):
cls.path = "/api/v2/schedule/"
cls.path = "/api/v2/schedule"
cls.token = settings.CONFIG.general.api_key
def test_schedule_item_full_length(self):

View file

@ -2,7 +2,7 @@ from rest_framework import routers
from .views import FileViewSet, LibraryViewSet
router = routers.DefaultRouter()
router = routers.DefaultRouter(trailing_slash=False)
router.register("files", FileViewSet)
router.register("libraries", LibraryViewSet)

View file

@ -8,7 +8,7 @@ from ...._fixtures import AUDIO_FILENAME
class TestFileViewSet(APITestCase):
@classmethod
def setUpTestData(cls):
cls.path = "/api/v2/files/{id}/download/"
cls.path = "/api/v2/files/{id}/download"
cls.token = settings.CONFIG.general.api_key
def test_invalid(self):

View file

@ -11,7 +11,7 @@ from ..permissions import IsSystemTokenOrUser
class TestIsSystemTokenOrUser(APITestCase):
@classmethod
def setUpTestData(cls):
cls.path = "/api/v2/files/"
cls.path = "/api/v2/files"
def test_unauthorized(self):
response = self.client.get(self.path.format("files"))
@ -67,7 +67,7 @@ class TestPermissions(APITestCase):
@classmethod
def setUpTestData(cls):
cls.path = "/api/v2/{}/"
cls.path = "/api/v2/{}"
def test_guest_permissions_success(self):
for model in self.URLS:

View file

@ -24,12 +24,12 @@ api_urls += storage_urls
urlpatterns = [
path("api/v2/", include(api_urls)),
path(
"api/v2/schema/",
"api/v2/schema",
SpectacularAPIView.as_view(),
name="schema",
),
path(
"api/v2/schema/swagger-ui/",
"api/v2/schema/swagger-ui",
SpectacularSwaggerView.as_view(url_name="schema"),
name="swagger-ui",
),