From e8a2f4df7368ad7e3de4c992e89f96e8ec242da1 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 15 Feb 2024 10:15:12 +0000 Subject: [PATCH] Bug 36100: Remove readOnly from bookings definition. Whilst readOnly feels correct here, swagger doesn't work that way at our version. It must be removed to restore the ability to edit exising bookings. Signed-off-by: David Nind Signed-off-by: Marcel de Rooy Signed-off-by: Katrin Fischer --- Koha/REST/V1/Bookings.pm | 9 ++++++++- api/v1/swagger/definitions/booking.yaml | 1 - 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Koha/REST/V1/Bookings.pm b/Koha/REST/V1/Bookings.pm index f4e15013ef..0e355f23dd 100644 --- a/Koha/REST/V1/Bookings.pm +++ b/Koha/REST/V1/Bookings.pm @@ -83,7 +83,7 @@ sub add { $c->res->headers->location( $c->req->url->to_string . '/' . $booking->booking_id ); return $c->render( status => 201, - openapi => $c->objects->to_api( $booking ), + openapi => $c->objects->to_api($booking), ); } catch { if ( blessed $_ and $_->isa('Koha::Exceptions::Booking::Clash') ) { @@ -91,6 +91,13 @@ sub add { status => 400, openapi => { error => "Booking would conflict" } ); + } elsif ( blessed $_ and $_->isa('Koha::Exceptions::Object::DuplicateID') ) { + return $c->render( + status => 400, + openapi => { + error => "Duplicate booking_id", + } + ); } return $c->unhandled_exception($_); diff --git a/api/v1/swagger/definitions/booking.yaml b/api/v1/swagger/definitions/booking.yaml index a615bb9ed8..23393a60ff 100644 --- a/api/v1/swagger/definitions/booking.yaml +++ b/api/v1/swagger/definitions/booking.yaml @@ -10,7 +10,6 @@ properties: booking_id: description: Internal booking identifier type: integer - readOnly: true end_date: description: Start date and time of this booking format: date-time -- 2.39.5