From 517399674d0bcf23b5b2731b476a8b7647dbaa6f Mon Sep 17 00:00:00 2001
From: Chris Pastl <chris@crispybits.app>
Date: Mon, 17 Jun 2024 15:08:56 +0200
Subject: [PATCH] refactor: add custom OpenAPI examples to playout endpoint

---
 program/views.py | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

diff --git a/program/views.py b/program/views.py
index b70e0d78..440a3e3a 100644
--- a/program/views.py
+++ b/program/views.py
@@ -25,6 +25,7 @@ from textwrap import dedent
 
 from django_filters.rest_framework import DjangoFilterBackend
 from drf_spectacular.utils import (
+    OpenApiExample,
     OpenApiParameter,
     OpenApiResponse,
     OpenApiTypes,
@@ -191,7 +192,38 @@ class APIDayScheduleViewSet(
             "Returns a list of the scheduled playout. "
             "The schedule will include virtual timeslots to fill unscheduled gaps if requested."
         ),
-    ),
+        examples=[
+            OpenApiExample(
+                "Regular timeslot example",
+                summary="Regular timeslot",
+                description="Example values for a regular timeslot",
+                value={
+                    "end": "2024-06-19T20:30:00 +0000",
+                    "id": 2,
+                    "isVirtual": False,
+                    "playlistId": None,
+                    "repetitionOfId": None,
+                    "scheduleId": 9,
+                    "showDefaultPlaylistId": None,
+                    "showId": 3,
+                    "showName": "The Live Show",
+                    "start": "2024-06-17T12:42:47.038Z",
+                },
+            ),
+            OpenApiExample(
+                "Virtual timeslot example",
+                summary="Virtual timeslot",
+                description="Example values for a virtual timeslot",
+                value={
+                    "end": "2024-06-19T20:30:00 +0000",
+                    "isVirtual": True,
+                    "showId": 1,
+                    "showName": "Musicpool",
+                    "start": "2024-06-19T15:00:00 +0000",
+                },
+            ),
+        ],
+    )
 )
 class APIPlayoutViewSet(
     mixins.ListModelMixin,
-- 
GitLab