api: fix pagination schema

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-05-16 15:08:51 +02:00
parent 3ab7588b73
commit 4fb71a6bdd
4 changed files with 1231 additions and 912 deletions

View file

@ -30,3 +30,37 @@ class Pagination(pagination.PageNumberPagination):
"results": data,
}
)
def get_paginated_response_schema(self, schema):
return {
"type": "object",
"properties": {
"pagination": {
"type": "object",
"properties": {
"next": {
"type": "number",
},
"previous": {
"type": "number",
},
"count": {
"type": "number",
},
"current": {
"type": "number",
},
"total_pages": {
"type": "number",
},
"start_index": {
"type": "number",
},
"end_index": {
"type": "number",
},
},
},
"results": schema,
},
}

View file

@ -6,7 +6,12 @@ from django.http.response import HttpResponse
from django.shortcuts import get_object_or_404
from django.utils.translation import gettext_lazy as _
from drf_spectacular.types import OpenApiTypes
from drf_spectacular.utils import OpenApiParameter, OpenApiResponse, extend_schema, extend_schema_field
from drf_spectacular.utils import (
OpenApiParameter,
OpenApiResponse,
extend_schema,
extend_schema_field,
)
from rest_framework.decorators import action
from rest_framework.fields import CharField, FileField, ReadOnlyField
from rest_framework.parsers import MultiPartParser

View file

@ -154,7 +154,7 @@ SPECTACULAR_SETTINGS = {
"ENUM_NAME_OVERRIDES": {
"ChallengeChoices": "authentik.flows.challenge.ChallengeTypes"
},
"ENUM_ADD_EXPLICIT_BLANK_NULL_CHOICE": False
"ENUM_ADD_EXPLICIT_BLANK_NULL_CHOICE": False,
}
REST_FRAMEWORK = {

2100
schema.yml

File diff suppressed because it is too large Load diff