Bugzilla – Attachment 115810 Details for
Bug 27352
Add GET /biblios/:biblio_id/items
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27352: Add GET /biblios/:biblio_id/items
Bug-27352-Add-GET-bibliosbiblioiditems.patch (text/plain), 5.30 KB, created by
Martin Renvoize (ashimema)
on 2021-01-26 12:52:06 UTC
(
hide
)
Description:
Bug 27352: Add GET /biblios/:biblio_id/items
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-01-26 12:52:06 UTC
Size:
5.30 KB
patch
obsolete
>From 4e048276e32112595af1acd1ff68cac892e6a378 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 6 Jan 2021 12:00:40 -0300 >Subject: [PATCH] Bug 27352: Add GET /biblios/:biblio_id/items > >This patch adds a route to fetch the items for a biblio. It relies >entirely on already existing methods. > >To test: >1. Use your favourite REST tool >2. Play with the new route. >=> SUCCESS: It works as expected! > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/REST/V1/Biblios.pm | 34 +++++++++++ > api/v1/swagger/paths.json | 9 ++- > api/v1/swagger/paths/biblios.json | 98 +++++++++++++++++++++++++++++++ > 3 files changed, 138 insertions(+), 3 deletions(-) > >diff --git a/Koha/REST/V1/Biblios.pm b/Koha/REST/V1/Biblios.pm >index 157282b4a1..4e803b1988 100644 >--- a/Koha/REST/V1/Biblios.pm >+++ b/Koha/REST/V1/Biblios.pm >@@ -237,4 +237,38 @@ sub get_public { > }; > } > >+=head3 get_items >+ >+Controller function that handles retrieving biblio's items >+ >+=cut >+ >+sub get_items { >+ my $c = shift->openapi->valid_input or return; >+ >+ my $biblio = Koha::Biblios->find( { biblionumber => $c->validation->param('biblio_id') }, { prefetch => ['items'] } ); >+ >+ unless ( $biblio ) { >+ return $c->render( >+ status => 404, >+ openapi => { >+ error => "Object not found." >+ } >+ ); >+ } >+ >+ return try { >+ >+ my $items_rs = $biblio->items; >+ my $items = $c->objects->search( $items_rs ); >+ return $c->render( >+ status => 200, >+ openapi => $items >+ ); >+ } >+ catch { >+ $c->unhandled_exception($_); >+ }; >+} >+ > 1; >diff --git a/api/v1/swagger/paths.json b/api/v1/swagger/paths.json >index 3b5dc352d5..e871e54ed4 100644 >--- a/api/v1/swagger/paths.json >+++ b/api/v1/swagger/paths.json >@@ -17,6 +17,12 @@ > "/acquisitions/funds": { > "$ref": "paths/acquisitions_funds.json#/~1acquisitions~1funds" > }, >+ "/biblios/{biblio_id}": { >+ "$ref": "paths/biblios.json#/~1biblios~1{biblio_id}" >+ }, >+ "/biblios/{biblio_id}/items": { >+ "$ref": "paths/biblios.json#/~1biblios~1{biblio_id}~1items" >+ }, > "/checkouts": { > "$ref": "paths/checkouts.json#/~1checkouts" > }, >@@ -35,9 +41,6 @@ > "/cities/{city_id}": { > "$ref": "paths/cities.json#/~1cities~1{city_id}" > }, >- "/biblios/{biblio_id}": { >- "$ref": "paths/biblios.json#/~1biblios~1{biblio_id}" >- }, > "/clubs/{club_id}/holds": { > "$ref": "paths/clubs.json#/~1clubs~1{club_id}~1holds" > }, >diff --git a/api/v1/swagger/paths/biblios.json b/api/v1/swagger/paths/biblios.json >index 4896b71f62..0b95576204 100644 >--- a/api/v1/swagger/paths/biblios.json >+++ b/api/v1/swagger/paths/biblios.json >@@ -134,6 +134,104 @@ > } > } > }, >+ "/biblios/{biblio_id}/items": { >+ "get": { >+ "x-mojo-to": "Biblios#get_items", >+ "operationId": "getBiblioItems", >+ "tags": [ >+ "biblios", >+ "items" >+ ], >+ "parameters": [ >+ { >+ "$ref": "../parameters.json#/biblio_id_pp" >+ }, >+ { >+ "$ref": "../parameters.json#/match" >+ }, >+ { >+ "$ref": "../parameters.json#/order_by" >+ }, >+ { >+ "$ref": "../parameters.json#/page" >+ }, >+ { >+ "$ref": "../parameters.json#/per_page" >+ }, >+ { >+ "$ref": "../parameters.json#/q_param" >+ }, >+ { >+ "$ref": "../parameters.json#/q_body" >+ }, >+ { >+ "$ref": "../parameters.json#/q_header" >+ } >+ ], >+ "consumes": [ >+ "application/json" >+ ], >+ "produces": [ >+ "application/json" >+ ], >+ "responses": { >+ "200": { >+ "description": "A list of the items attached to the record", >+ "schema": { >+ "type": "array", >+ "items": { >+ "$ref": "../definitions.json#/item" >+ } >+ } >+ }, >+ "401": { >+ "description": "Authentication required", >+ "schema": { >+ "$ref": "../definitions.json#/error" >+ } >+ }, >+ "403": { >+ "description": "Access forbidden", >+ "schema": { >+ "$ref": "../definitions.json#/error" >+ } >+ }, >+ "404": { >+ "description": "Biblio not found", >+ "schema": { >+ "$ref": "../definitions.json#/error" >+ } >+ }, >+ "406": { >+ "description": "Not acceptable", >+ "schema": { >+ "type": "array", >+ "description": "Accepted content-types", >+ "items": { >+ "type": "string" >+ } >+ } >+ }, >+ "500": { >+ "description": "Internal server error", >+ "schema": { >+ "$ref": "../definitions.json#/error" >+ } >+ }, >+ "503": { >+ "description": "Under maintenance", >+ "schema": { >+ "$ref": "../definitions.json#/error" >+ } >+ } >+ }, >+ "x-koha-authorization": { >+ "permissions": { >+ "catalogue": "1" >+ } >+ } >+ } >+ }, > "/public/biblios/{biblio_id}": { > "get": { > "x-mojo-to": "Biblios#get_public", >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 27352
:
114892
|
114894
|
114895
|
114983
|
114984
|
114985
| 115810 |
115811
|
115812