feat(api): don't use trailing slashes (#1982)
This commit is contained in:
parent
368350b269
commit
f08af1f3fa
10 changed files with 85 additions and 85 deletions
|
@ -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()),
|
||||
]
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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",
|
||||
),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue