Merge pull request 'write swagger docs' (#82) from behruz into main
All checks were successful
Deploy to Production / build-and-deploy (push) Successful in 1m56s
All checks were successful
Deploy to Production / build-and-deploy (push) Successful in 1m56s
Reviewed-on: #82
This commit is contained in:
@@ -1,10 +1,28 @@
|
||||
from rest_framework import generics
|
||||
from rest_framework.permissions import IsAuthenticated
|
||||
|
||||
from drf_spectacular.utils import extend_schema, OpenApiParameter
|
||||
from drf_spectacular.types import OpenApiTypes
|
||||
|
||||
from core.apps.shared.serializers.region.district import DistrictSerializer, VillageSerializer, RegionSerializer
|
||||
from core.apps.shared.models import RegionModel, VillageModel, DistrictModel
|
||||
|
||||
|
||||
@extend_schema(
|
||||
parameters=[
|
||||
OpenApiParameter(
|
||||
name="region",
|
||||
type=OpenApiTypes.INT,
|
||||
location=OpenApiParameter.QUERY,
|
||||
description="Filter by region ID"
|
||||
),
|
||||
OpenApiParameter(
|
||||
name="name",
|
||||
type=OpenApiTypes.STR,
|
||||
location=OpenApiParameter.QUERY,
|
||||
description="Filter by district name"
|
||||
),
|
||||
]
|
||||
)
|
||||
class DistrictListCreateView(generics.ListCreateAPIView):
|
||||
permission_classes = [IsAuthenticated]
|
||||
serializer_class = DistrictSerializer
|
||||
@@ -19,7 +37,22 @@ class DistrictListCreateView(generics.ListCreateAPIView):
|
||||
return self.queryset.filter(region=region)
|
||||
return super().get_queryset()
|
||||
|
||||
|
||||
@extend_schema(
|
||||
parameters=[
|
||||
OpenApiParameter(
|
||||
name="district",
|
||||
type=OpenApiTypes.INT,
|
||||
location=OpenApiParameter.QUERY,
|
||||
description="Filter by district ID"
|
||||
),
|
||||
OpenApiParameter(
|
||||
name="name",
|
||||
type=OpenApiTypes.STR,
|
||||
location=OpenApiParameter.QUERY,
|
||||
description="Filter by village name"
|
||||
),
|
||||
]
|
||||
)
|
||||
class VillageListCreateView(generics.ListCreateAPIView):
|
||||
permission_classes = [IsAuthenticated]
|
||||
serializer_class = VillageSerializer
|
||||
|
||||
Reference in New Issue
Block a user