From 3e65532c19e965d61972afab0e05b1fbf56c6273 Mon Sep 17 00:00:00 2001 From: Romain Le Cellier Date: Mon, 27 Feb 2023 17:09:31 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9(schema):=20add=20course=20query=20?= =?UTF-8?q?param=20to=20product=20retrieve=20route?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit course is a mandatory query param for product.retrieve. we need it in order to correctly generate javascript api client. --- CHANGELOG.md | 1 + src/backend/joanie/core/api.py | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c516455b9c..2af5501302 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to ## Added - Add yarn cli to generate joanie api client in TypeScript +- Add course query param to openapi schema on route products.retrieve ### Removed diff --git a/src/backend/joanie/core/api.py b/src/backend/joanie/core/api.py index 74d2cb8de9..1b64fdc2c3 100644 --- a/src/backend/joanie/core/api.py +++ b/src/backend/joanie/core/api.py @@ -6,6 +6,8 @@ from django.http import HttpResponse from django.utils.translation import gettext_lazy as _ +from drf_yasg import openapi +from drf_yasg.utils import swagger_auto_schema from rest_framework import mixins, pagination, permissions, viewsets from rest_framework.decorators import action from rest_framework.exceptions import ValidationError as DRFValidationError @@ -110,6 +112,14 @@ def get_serializer_context(self): return context + @swagger_auto_schema( + manual_parameters=[ + openapi.Parameter("course", in_=openapi.IN_QUERY, type=openapi.TYPE_STRING) + ], + ) + def retrieve(self, *args, **kwargs): + return super().retrieve(*args, **kwargs) + # pylint: disable=too-many-ancestors class EnrollmentViewSet(