Skip to content

Commit

Permalink
✨ Add schema
Browse files Browse the repository at this point in the history
Removes pagination as per the reference openapi spec.
  • Loading branch information
CharString committed Dec 22, 2023
1 parent c844f2e commit 0980238
Show file tree
Hide file tree
Showing 20 changed files with 5,737 additions and 28 deletions.
20 changes: 20 additions & 0 deletions src/openklant/components/referentielijsten/api/schema.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from django.conf import settings

from drf_yasg import openapi

description = """
Een API om de referentielijsten in het domein klantinteracties te raadplegen en beheren.
""".strip()

info = openapi.Info(
title="Klantinteracties Referentielijsten",
default_version=settings.REFERENTIELIJSTEN_API_VERSION,
description=description,
contact=openapi.Contact(
email="[email protected]",
url="https://vng-realisatie.github.io/klantinteracties/",
),
license=openapi.License(
name="EUPL 1.2", url="https://opensource.org/licenses/EUPL-1.2"
),
)
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ def test_getexterneregisters(self):
response = self.client.get(url)
self.assertEqual(response.status_code, status.HTTP_200_OK)
response_data = response.json()
self.assertEqual(response_data["count"], 1000)
self.assertLess(len(response_data["results"]), 1000)
self.assertEqual(len(response_data), 1000)

def test_postregister(self):
url = reverse("referentielijsten:externregister-list")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def test_getkanalen(self):
response = self.client.get(url)
self.assertEqual(response.status_code, status.HTTP_200_OK)
response_data = response.json()
self.assertEqual(response_data["count"], 6)
self.assertEqual(len(response_data), 6)

def test_postkanaal(self):
url = reverse("referentielijsten:kanaal-list")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def test_getlanden(self):
response = self.client.get(url)
self.assertEqual(response.status_code, status.HTTP_200_OK)
response_data = response.json()
self.assertEqual(response_data["count"], 6)
self.assertEqual(len(response_data), 6)

def test_postland(self):
url = reverse("referentielijsten:land-list")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def test_getsoortendigitaaladres(self):
response = self.client.get(url)
self.assertEqual(response.status_code, status.HTTP_200_OK)
response_data = response.json()
self.assertEqual(response_data["count"], 6)
self.assertEqual(len(response_data), 6)

def test_postsoortdigitaaladres(self):
url = reverse("referentielijsten:soortdigitaaladres-list")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def test_getsoortenobject(self):
response = self.client.get(url)
self.assertEqual(response.status_code, status.HTTP_200_OK)
response_data = response.json()
self.assertEqual(response_data["count"], 6)
self.assertEqual(len(response_data), 6)

def test_postsoortobject(self):
url = reverse("referentielijsten:soortobject-list")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def test_getsoortenobjectid(self):
response = self.client.get(url)
self.assertEqual(response.status_code, status.HTTP_200_OK)
response_data = response.json()
self.assertEqual(response_data["count"], 6)
self.assertEqual(len(response_data), 6)

def test_postsoortobjectid(self):
url = reverse("referentielijsten:soortobjectid-list")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def test_gettalen(self):
response = self.client.get(url)
self.assertEqual(response.status_code, status.HTTP_200_OK)
response_data = response.json()
self.assertEqual(response_data["count"], 6)
self.assertEqual(len(response_data), 6)

def test_posttaal(self):
url = reverse("referentielijsten:taal-list")
Expand Down
25 changes: 20 additions & 5 deletions src/openklant/components/referentielijsten/api/urls.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from django.conf import settings
from django.urls import include, path
from django.urls import include, path, re_path

from vng_api_common import routers
from vng_api_common import routers, schema

from . import viewsets
from .schema import info

app_name = "referentielijsten"

Expand All @@ -17,13 +18,27 @@
router.register("talen", viewsets.TaalViewSet)


class SchemaView(schema.SchemaView):
schema_path = settings.SPEC_URL["referentielijsten"]
info = info


urlpatterns = [
path(
"v<slug:version>/",
"v<version>/",
include(
[
# TODO API documentation
# re_path(r"^schema/openapi(?P<format>\.json|\.yaml)$",
# API documentation
re_path(
r"^schema/openapi(?P<format>\.json|\.yaml)$",
SchemaView.without_ui(cache_timeout=None),
name="schema-json-referentielijsten",
),
path(
"schema/",
SchemaView.with_ui("redoc", cache_timeout=None),
name="schema-redoc-klantinteracties",
),
path("", include(router.urls)),
]
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from rest_framework import viewsets
from rest_framework.pagination import PageNumberPagination

from ...models import ExternRegister
from ..serializers import ExternRegisterSerializer


class ExternRegisterViewSet(viewsets.ModelViewSet):
__doc__ = ExternRegister.__doc__
lookup_field = "code"
pagination_class = PageNumberPagination
pagination_class = None
queryset = ExternRegister.objects.order_by("-pk")
serializer_class = ExternRegisterSerializer
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from rest_framework import viewsets
from rest_framework.pagination import PageNumberPagination

from ...models import Kanaal
from ..serializers import KanaalSerializer


class KanaalViewSet(viewsets.ModelViewSet):
__doc__ = Kanaal.__doc__
lookup_field = "code"
pagination_class = PageNumberPagination
pagination_class = None
queryset = Kanaal.objects.order_by("-pk")
serializer_class = KanaalSerializer
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from rest_framework import viewsets
from rest_framework.pagination import PageNumberPagination

from ...models import Land
from ..serializers import LandSerializer


class LandViewSet(viewsets.ModelViewSet):
# TODO? filterset_class filter vigerend?
__doc__ = Land.__doc__
lookup_field = "landcode"
pagination_class = PageNumberPagination
pagination_class = None
queryset = Land.objects.order_by("-pk")
serializer_class = LandSerializer
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from rest_framework import viewsets
from rest_framework.pagination import PageNumberPagination

from ...models import SoortDigitaalAdres
from ..serializers import SoortDigitaalAdresSerializer


class SoortDigitaalAdresViewSet(viewsets.ModelViewSet):
__doc__ = SoortDigitaalAdres.__doc__
lookup_field = "code"
pagination_class = PageNumberPagination
pagination_class = None
queryset = SoortDigitaalAdres.objects.order_by("-pk")
serializer_class = SoortDigitaalAdresSerializer
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from rest_framework import viewsets
from rest_framework.pagination import PageNumberPagination

from ...models import SoortObject
from ..serializers import SoortObjectSerializer


class SoortObjectViewSet(viewsets.ModelViewSet):
__doc__ = SoortObject.__doc__
lookup_field = "code"
pagination_class = PageNumberPagination
pagination_class = None
queryset = SoortObject.objects.order_by("-pk")
serializer_class = SoortObjectSerializer
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from rest_framework import viewsets
from rest_framework.pagination import PageNumberPagination

from ...models import SoortObjectid
from ..serializers import SoortObjectidSerializer


class SoortObjectidViewSet(viewsets.ModelViewSet):
__doc__ = SoortObjectid.__doc__
lookup_field = "code"
pagination_class = PageNumberPagination
pagination_class = None
queryset = SoortObjectid.objects.order_by("-pk")
serializer_class = SoortObjectidSerializer
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from rest_framework import viewsets
from rest_framework.pagination import PageNumberPagination

from ...models import Taal
from ..serializers import TaalSerializer


class TaalViewSet(viewsets.ModelViewSet):
__doc__ = Taal.__doc__
lookup_field = "code"
pagination_class = PageNumberPagination
pagination_class = None
queryset = Taal.objects.order_by("-pk")
serializer_class = TaalSerializer
Loading

0 comments on commit 0980238

Please sign in to comment.