From a9a808aae65bfa80290bed133fddb83df224d002 Mon Sep 17 00:00:00 2001 From: Sonny Bakker Date: Thu, 5 Sep 2024 14:33:13 +0200 Subject: [PATCH] [#328] update path parameter documentation --- src/objects/api/v2/openapi.yaml | 4 +--- src/objects/api/v2/views.py | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/objects/api/v2/openapi.yaml b/src/objects/api/v2/openapi.yaml index f37efe8e..e478db17 100644 --- a/src/objects/api/v2/openapi.yaml +++ b/src/objects/api/v2/openapi.yaml @@ -474,15 +474,13 @@ paths: - in: path name: index schema: - type: string - pattern: ^\d+$ + type: number required: true - in: path name: uuid schema: type: string format: uuid - description: Unique identifier (UUID4) required: true tags: - objects diff --git a/src/objects/api/v2/views.py b/src/objects/api/v2/views.py index 2d7e4e10..175f63aa 100644 --- a/src/objects/api/v2/views.py +++ b/src/objects/api/v2/views.py @@ -3,7 +3,8 @@ from django.conf import settings from django.db import models -from drf_spectacular.utils import extend_schema, extend_schema_view +from drf_spectacular.types import OpenApiTypes +from drf_spectacular.utils import OpenApiParameter, extend_schema, extend_schema_view from rest_framework import mixins, viewsets from rest_framework.decorators import action from rest_framework.generics import get_object_or_404 @@ -124,6 +125,20 @@ def history(self, request, uuid=None): @extend_schema( description="Retrieve the specified OBJECT given an UUID and INDEX.", responses={"200": HistoryRecordSerializer()}, + parameters=[ + OpenApiParameter( + name="index", + location=OpenApiParameter.PATH, + required=True, + type=OpenApiTypes.NUMBER, + ), + OpenApiParameter( + name="uuid", + location=OpenApiParameter.PATH, + required=True, + type=OpenApiTypes.UUID, + ), + ] ) @action( detail=True,