From c00766b7167ec391d343d34f50ad480132620e0f 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. Content-Type: text/plain; charset=utf-8 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 --- 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.30.2