Skip to content

Commit

Permalink
Fix auth urls (to match with FastAPI)
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Aug 12, 2024
1 parent 18d1b61 commit 1ff1899
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion open_prices/api/auth/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
class LoginView(APIView):
serializer_class = LoginSerializer

@extend_schema(responses=SessionResponseSerializer)
@extend_schema(responses=SessionResponseSerializer, tags=["auth"])
def post(self, request: Request) -> Response:
"""
Authentication: provide username/password
Expand Down Expand Up @@ -85,6 +85,7 @@ class SessionView(APIView):
permission_classes = [IsAuthenticated]
serializer_class = SessionFullSerializer

@extend_schema(tags=["auth"])
def get(self, request: Request) -> Response:
session = get_request_session(request)
return Response(
Expand All @@ -96,6 +97,7 @@ def get(self, request: Request) -> Response:
}
)

@extend_schema(tags=["auth"])
def delete(self, request: Request) -> Response:
session = get_request_session(request)
session.delete()
Expand Down
7 changes: 5 additions & 2 deletions open_prices/api/urls.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from django.urls import include, path
from django.urls import path
from drf_spectacular.views import (
SpectacularAPIView,
SpectacularRedocView,
SpectacularSwaggerView,
)
from rest_framework import routers

from open_prices.api.auth.views import LoginView, SessionView
from open_prices.api.locations.views import LocationViewSet
from open_prices.api.prices.views import PriceViewSet
from open_prices.api.products.views import ProductViewSet
Expand All @@ -23,7 +24,9 @@
router.register(r"v1/prices", PriceViewSet, basename="prices")

urlpatterns = [
path("v1/auth/", include("open_prices.api.auth.urls")),
# auth urls
path("v1/auth", LoginView.as_view(), name="login"),
path("v1/session", SessionView.as_view(), name="session"),
# health check
path("status", StatusView.as_view(), name="status"),
# Swagger / OpenAPI documentation
Expand Down

0 comments on commit 1ff1899

Please sign in to comment.