Bugzilla – Attachment 190565 Details for
Bug 41463
Add Koha REST API endpoints for OAI sets
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 41463: [WIP] oai_sets REST API endpoint
Bug-41463-WIP-oaisets-REST-API-endpoint.patch (text/plain), 5.19 KB, created by
Aleisha Amohia
on 2025-12-17 04:00:42 UTC
(
hide
)
Description:
Bug 41463: [WIP] oai_sets REST API endpoint
Filename:
MIME Type:
Creator:
Aleisha Amohia
Created:
2025-12-17 04:00:42 UTC
Size:
5.19 KB
patch
obsolete
>From b1e423c0e91f53ee3e037dc0b4ee4efe228e179e Mon Sep 17 00:00:00 2001 >From: Aleisha Amohia <aleisha@catalyst.net.nz> >Date: Wed, 17 Dec 2025 04:00:12 +0000 >Subject: [PATCH] Bug 41463: [WIP] oai_sets REST API endpoint > >--- > Koha/REST/V1/OAI/Sets.pm | 58 +++++++++++++++++++++++++ > api/v1/swagger/definitions/oai_set.yaml | 21 +++++++++ > api/v1/swagger/paths/oai_sets.yaml | 47 ++++++++++++++++++++ > api/v1/swagger/swagger.yaml | 4 ++ > 4 files changed, 130 insertions(+) > create mode 100644 Koha/REST/V1/OAI/Sets.pm > create mode 100644 api/v1/swagger/definitions/oai_set.yaml > create mode 100644 api/v1/swagger/paths/oai_sets.yaml > >diff --git a/Koha/REST/V1/OAI/Sets.pm b/Koha/REST/V1/OAI/Sets.pm >new file mode 100644 >index 00000000000..8bbda476acd >--- /dev/null >+++ b/Koha/REST/V1/OAI/Sets.pm >@@ -0,0 +1,58 @@ >+package Koha::REST::V1::OAI::Sets; >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <https://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Mojo::Base 'Mojolicious::Controller'; >+ >+use Try::Tiny qw( catch try ); >+ >+use Koha::OAI::Sets; >+ >+=head1 NAME >+ >+Koha::REST::V1::OAI::Sets; >+ >+=head1 API >+ >+=head2 Methods >+ >+=head3 get >+ >+Controller function that handles retrieving an OAI set >+ >+=cut >+ >+sub get { >+ my $c = shift->openapi->valid_input or return; >+ >+ return try { >+ my $set = Koha::OAI::Sets->find( $c->param('set_id') ); >+ >+ return $c->render_resource_not_found("OAI set") >+ unless $set; >+ >+ return $c->render( >+ status => 200, >+ openapi => $c->objects->to_api($set), >+ ); >+ } catch { >+ $c->unhandled_exception($_); >+ } >+} >+ >+1; >diff --git a/api/v1/swagger/definitions/oai_set.yaml b/api/v1/swagger/definitions/oai_set.yaml >new file mode 100644 >index 00000000000..57cd6b545da >--- /dev/null >+++ b/api/v1/swagger/definitions/oai_set.yaml >@@ -0,0 +1,21 @@ >+--- >+type: object >+properties: >+ set_id: >+ type: integer >+ description: Internal OAI set identifier >+ spec: >+ type: string >+ description: Indicates a hierarchy of sets >+ name: >+ type: string >+ description: Name of set >+ total_count: >+ type: integer >+ description: Number of total items in the set >+ catalog_count: >+ type: integer >+ description: Number of items which exist both in the set and in the catalog >+additionalProperties: false >+required: >+ - set_id >diff --git a/api/v1/swagger/paths/oai_sets.yaml b/api/v1/swagger/paths/oai_sets.yaml >new file mode 100644 >index 00000000000..d87857773d0 >--- /dev/null >+++ b/api/v1/swagger/paths/oai_sets.yaml >@@ -0,0 +1,47 @@ >+--- >+"/oai_sets/{set_id}": >+ get: >+ x-mojo-to: OAI::Sets#get >+ operationId: getOAISet >+ tags: >+ - oai_sets >+ summary: Get OAI set >+ parameters: >+ - name: set_id >+ in: path >+ description: Internal OAI set identifier >+ required: true >+ type: integer >+ produces: >+ - application/json >+ responses: >+ "200": >+ description: An OAI set >+ schema: >+ $ref: "../swagger.yaml#/definitions/oai_set" >+ "400": >+ description: Bad request >+ schema: >+ $ref: "../swagger.yaml#/definitions/error" >+ "403": >+ description: Access forbidden >+ schema: >+ $ref: "../swagger.yaml#/definitions/error" >+ "404": >+ description: Patron not found >+ schema: >+ $ref: "../swagger.yaml#/definitions/error" >+ "500": >+ description: | >+ Internal server error. Possible `error_code` attribute values: >+ >+ * `internal_server_error` >+ schema: >+ $ref: "../swagger.yaml#/definitions/error" >+ "503": >+ description: Under maintenance >+ schema: >+ $ref: "../swagger.yaml#/definitions/error" >+ x-koha-authorization: >+ permissions: >+ parameters: manage_oai_sets >diff --git a/api/v1/swagger/swagger.yaml b/api/v1/swagger/swagger.yaml >index dcb0a3cc66e..8ac7f73d130 100644 >--- a/api/v1/swagger/swagger.yaml >+++ b/api/v1/swagger/swagger.yaml >@@ -142,6 +142,8 @@ definitions: > $ref: ./definitions/list.yaml > merge_biblios: > $ref: ./definitions/merge_biblios.yaml >+ oai_set: >+ $ref: ./definitions/oai_set.yaml > order: > $ref: ./definitions/order.yaml > order_claim: >@@ -483,6 +485,8 @@ paths: > $ref: "./paths/libraries.yaml#/~1libraries~1{library_id}~1cash_registers" > "/libraries/{library_id}/desks": > $ref: "./paths/libraries.yaml#/~1libraries~1{library_id}~1desks" >+ "/oai_sets/{set_id}": >+ $ref: "./paths/oai_sets.yaml#/~1oai_sets~1{set_id}" > "/oauth/login/{provider_code}/{interface}": > $ref: ./paths/oauth.yaml#/~1oauth~1login~1{provider_code}~1{interface} > /oauth/token: >-- >2.39.5
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 41463
:
190565
|
190610
|
190631