Bugzilla – Attachment 147888 Details for
Bug 33161
Implement +strings for GET /items and GET /items/:item_id
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33161: Add +strings support to GET /items and /items/:item_id [WIP]
Bug-33161-Add-strings-support-to-GET-items-and-ite.patch (text/plain), 4.33 KB, created by
Tomás Cohen Arazi
on 2023-03-08 01:07:50 UTC
(
hide
)
Description:
Bug 33161: Add +strings support to GET /items and /items/:item_id [WIP]
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi
Created:
2023-03-08 01:07:50 UTC
Size:
4.33 KB
patch
obsolete
>From bbd3508a112add5dfb0a0bb04ecc525d73c7a6ca Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Tue, 7 Mar 2023 20:51:35 -0300 >Subject: [PATCH] Bug 33161: Add +strings support to GET /items and > /items/:item_id [WIP] > >--- > Koha/Item.pm | 41 ++++++++++++++++++++++++++++ > Koha/REST/V1/Items.pm | 5 ++-- > api/v1/swagger/definitions/item.yaml | 4 +++ > api/v1/swagger/paths/items.yaml | 20 ++++++++++++++ > 4 files changed, 68 insertions(+), 2 deletions(-) > >diff --git a/Koha/Item.pm b/Koha/Item.pm >index 89d1a948c45..7f2f61ebbeb 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -2058,6 +2058,47 @@ sub is_denied_renewal { > return 0; > } > >+=head3 api_strings_mapping >+ >+Retrieves for each column name the unblessed authorised value. >+ >+=cut >+ >+sub api_strings_mapping { >+ my ( $self, $params ) = @_; >+ >+ my $columns_info = $self->_result->result_source->columns_info; >+ my $framworkcode = $self->biblio->frameworkcode; >+ >+ # Handle not null and default values for integers and dates >+ my $avs = {}; >+ foreach my $col ( keys %{$columns_info} ) { >+ next unless defined $self->$col; >+ my $field = $self->_result->result_source->name . '.' . $col; >+ my $mss = Koha::MarcSubfieldStructures->find( >+ { frameworkcode => $framworkcode, >+ kohafield => $field, >+ } >+ ); >+ if ( $mss && $mss->authorised_value ) { >+ my $av = Koha::AuthorisedValues->find( >+ { category => $mss->authorised_value, >+ authorised_value => $self->$col >+ } >+ ); >+ >+ $avs->{$col} = { >+ category => $mss->authorised_value, >+ str => $params->{public} ? $av->opac_description : $av->lib, >+ type => 'av', >+ } >+ if $av; >+ } >+ } >+ >+ return $avs; >+} >+ > =head3 _type > > =cut >diff --git a/Koha/REST/V1/Items.pm b/Koha/REST/V1/Items.pm >index 70abdfeeb2b..013ac03f157 100644 >--- a/Koha/REST/V1/Items.pm >+++ b/Koha/REST/V1/Items.pm >@@ -68,14 +68,15 @@ sub get { > my $c = shift->openapi->valid_input or return; > > try { >- my $item = Koha::Items->find($c->validation->param('item_id')); >+ my $items_rs = Koha::Items->new; >+ my $item = $c->objects->find($items_rs, $c->validation->param('item_id')); > unless ( $item ) { > return $c->render( > status => 404, > openapi => { error => 'Item not found'} > ); > } >- return $c->render( status => 200, openapi => $item->to_api ); >+ return $c->render( status => 200, openapi => $item ); > } > catch { > $c->unhandled_exception($_); >diff --git a/api/v1/swagger/definitions/item.yaml b/api/v1/swagger/definitions/item.yaml >index 069c0faebc2..21963d1ca46 100644 >--- a/api/v1/swagger/definitions/item.yaml >+++ b/api/v1/swagger/definitions/item.yaml >@@ -227,6 +227,10 @@ properties: > type: > - object > - "null" >+ _strings: >+ type: >+ - object >+ - "null" > description: A return claims object if one exists that's unresolved > additionalProperties: false > required: >diff --git a/api/v1/swagger/paths/items.yaml b/api/v1/swagger/paths/items.yaml >index 2bd8b212101..a9c7ca43c5e 100644 >--- a/api/v1/swagger/paths/items.yaml >+++ b/api/v1/swagger/paths/items.yaml >@@ -12,6 +12,16 @@ > description: Search on the item's barcode > required: false > type: string >+ - name: x-koha-embed >+ in: header >+ required: false >+ description: Embed list sent as a request header >+ type: array >+ items: >+ type: string >+ enum: >+ - +strings >+ collectionFormat: csv > - $ref: "../swagger.yaml#/parameters/match" > - $ref: "../swagger.yaml#/parameters/order_by" > - $ref: "../swagger.yaml#/parameters/page" >@@ -62,6 +72,16 @@ > summary: Get item > parameters: > - $ref: "../swagger.yaml#/parameters/item_id_pp" >+ - name: x-koha-embed >+ in: header >+ required: false >+ description: Embed list sent as a request header >+ type: array >+ items: >+ type: string >+ enum: >+ - +strings >+ collectionFormat: csv > consumes: > - application/json > produces: >-- >2.39.2
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 33161
:
147888
|
147973
|
147977
|
147995
|
147998
|
147999
|
148010
|
148011
|
148012
|
148013
|
148014
|
148039
|
148040
|
148041
|
148042
|
148043
|
148059
|
148060
|
148061
|
148062
|
148063
|
148068
|
148075