Self hosted FLOSS fitness/workout, nutrition and weight tracker
Correctly document the image thumnail endpoints
Roland Geideraaeeb9a3739b
diff --git a/wger/exercises/api/views.py b/wger/exercises/api/views.pyindex 0a3ce205d..c75a29f96 100644--- a/wger/exercises/api/views.py+++ b/wger/exercises/api/views.py@@ -25,6 +25,7 @@ from django.views.decorators.cache import cache_page# Third Partyfrom actstream import action as actstream_action+from drf_spectacular.utils import extend_schemafrom easy_thumbnails.alias import aliasesfrom easy_thumbnails.files import get_thumbnailerfrom rest_framework import viewsets@@ -65,6 +66,7 @@ from wger.exercises.models import (Translation,)from wger.exercises.views.helper import StreamVerbs+from wger.utils.api_schema import ImageThumbnailsSerializerfrom wger.utils.cache import CacheKeyMapper@@ -361,10 +363,11 @@ class ExerciseImageViewSet(ModelViewSet):def dispatch(self, request, *args, **kwargs):return super().dispatch(request, *args, **kwargs)+ @extend_schema(responses={200: ImageThumbnailsSerializer})@action(detail=True)def thumbnails(self, request, pk):"""- Return a list of the image's thumbnails+ Return the image's thumbnails, one per configured alias"""image = self.get_object()diff --git a/wger/utils/api_schema.py b/wger/utils/api_schema.pyindex 61cda7e07..8da039d1a 100644--- a/wger/utils/api_schema.py+++ b/wger/utils/api_schema.py@@ -27,3 +27,25 @@ class ThumbnailsSerializer(serializers.Serializer):small = serializers.URLField()medium = serializers.URLField()+++class ThumbnailAliasSerializer(serializers.Serializer):+ """+ One generated thumbnail: where it is and the size it was generated for.++ The url is relative to the server, unlike the absolute ones in an image's+ ``thumbnails`` field.+ """++ url = serializers.CharField()+ settings = serializers.DictField()+++class ImageThumbnailsSerializer(serializers.Serializer):+ """+ An image's thumbnails, one entry per available size, plus the original.+ """++ small = ThumbnailAliasSerializer()+ medium = ThumbnailAliasSerializer()+ original = serializers.CharField()