@@ -, +, @@ --- 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(-) --- a/Koha/REST/V1/Biblios.pm +++ a/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; --- a/api/v1/swagger/paths.json +++ a/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" }, --- a/api/v1/swagger/paths/biblios.json +++ a/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", --