Bugzilla – Attachment 158083 Details for
Bug 34008
REST API: Add a list (GET) endpoint for itemtypes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34008: (QA follow-up) 'item_type_id' should be used
Bug-34008-QA-follow-up-itemtypeid-should-be-used.patch (text/plain), 3.66 KB, created by
Tomás Cohen Arazi (tcohen)
on 2023-10-30 16:18:19 UTC
(
hide
)
Description:
Bug 34008: (QA follow-up) 'item_type_id' should be used
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2023-10-30 16:18:19 UTC
Size:
3.66 KB
patch
obsolete
>From 6b88670ad9fbd3928f193c42bd1882264d34c04f Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 30 Oct 2023 11:08:15 -0300 >Subject: [PATCH] Bug 34008: (QA follow-up) 'item_type_id' should be used > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/ItemType.pm | 8 +++----- > Koha/REST/V1/ItemTypes.pm | 8 +++----- > api/v1/swagger/definitions/item_type.yaml | 4 ++-- > t/db_dependent/api/v1/item_types.t | 7 +++---- > 4 files changed, 11 insertions(+), 16 deletions(-) > >diff --git a/Koha/ItemType.pm b/Koha/ItemType.pm >index 200ac166ea6..3aed3ec81f2 100644 >--- a/Koha/ItemType.pm >+++ b/Koha/ItemType.pm >@@ -221,14 +221,12 @@ on the API. > =cut > > sub to_api_mapping { >- return { 'itemtype' => 'item_type' }; >+ return { 'itemtype' => 'item_type_id' }; > } > >-sub from_api_mapping { >- return { 'item_type' => 'itemtype' }; >-} >+=head2 Internal methods > >-=head3 type >+=head3 _type > > =cut > >diff --git a/Koha/REST/V1/ItemTypes.pm b/Koha/REST/V1/ItemTypes.pm >index 91de0c4d0fd..497ec4c171d 100644 >--- a/Koha/REST/V1/ItemTypes.pm >+++ b/Koha/REST/V1/ItemTypes.pm >@@ -21,7 +21,7 @@ use Mojo::Base 'Mojolicious::Controller'; > > use Koha::ItemTypes; > >-use Try::Tiny; >+use Try::Tiny qw(catch try); > > =head1 API > >@@ -35,14 +35,12 @@ sub list { > my $c = shift->openapi->valid_input or return; > > return try { >- my $itemtypes_set = Koha::ItemTypes->new; >- my $itemtypes = $c->objects->search( $itemtypes_set ); >+ my $item_types = $c->objects->search( Koha::ItemTypes->new ); > >- return $c->render( status => 200, openapi => $itemtypes ); >+ return $c->render( status => 200, openapi => $item_types ); > } catch { > $c->unhandled_exception($_); > }; >- > } > > 1; >diff --git a/api/v1/swagger/definitions/item_type.yaml b/api/v1/swagger/definitions/item_type.yaml >index 6023869aa44..789fe5fcd91 100644 >--- a/api/v1/swagger/definitions/item_type.yaml >+++ b/api/v1/swagger/definitions/item_type.yaml >@@ -1,7 +1,7 @@ > --- > type: object > properties: >- item_type: >+ item_type_id: > type: string > description: Unique key, a code associated with the item type > readOnly: true >@@ -93,4 +93,4 @@ properties: > > additionalProperties: false > required: >- - item_type >+ - item_type_id >diff --git a/t/db_dependent/api/v1/item_types.t b/t/db_dependent/api/v1/item_types.t >index d45208ccfbc..c83c84d12b3 100755 >--- a/t/db_dependent/api/v1/item_types.t >+++ b/t/db_dependent/api/v1/item_types.t >@@ -32,7 +32,7 @@ my $builder = t::lib::TestBuilder->new; > my $t = Test::Mojo->new('Koha::REST::V1'); > t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); > >-subtest 'list_item_types() tests' => sub { >+subtest 'list() tests' => sub { > > plan tests => 12; > >@@ -109,11 +109,10 @@ subtest 'list_item_types() tests' => sub { > my $unauth_userid = $patron->userid; > > ## Authorized user tests >- # No category, 404 expected > $t->get_ok("//$userid:$password@/api/v1/item_types")->status_is(200)->json_has('/0'); > > for my $json ( @{ $t->tx->res->json } ) { >- if ( $json->{item_type} eq 'TEST_IT' ) { >+ if ( $json->{item_type_id} eq 'TEST_IT' ) { > is( $json->{description}, 'Test item type' ); > ok( !exists $json->{translated_descriptions} ); > } >@@ -123,7 +122,7 @@ subtest 'list_item_types() tests' => sub { > ->status_is(200)->json_has('/0'); > > for my $json ( @{ $t->tx->res->json } ) { >- if ( $json->{item_type} eq 'TEST_IT' ) { >+ if ( $json->{item_type_id} eq 'TEST_IT' ) { > is( $json->{description}, 'Test item type' ); > is_deeply( > $json->{translated_descriptions}, >-- >2.42.0
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 34008
:
155734
|
155737
|
155738
|
155739
|
155741
|
157915
|
157976
|
157977
|
158082
| 158083 |
158084