View | Details | Raw Unified | Return to bug 34008
Collapse All | Expand All

(-)a/Koha/ItemType.pm (-5 / +3 lines)
Lines 221-234 on the API. Link Here
221
=cut
221
=cut
222
222
223
sub to_api_mapping {
223
sub to_api_mapping {
224
    return { 'itemtype' => 'item_type' };
224
    return { 'itemtype' => 'item_type_id' };
225
}
225
}
226
226
227
sub from_api_mapping {
227
=head2 Internal methods
228
    return { 'item_type' => 'itemtype' };
229
}
230
228
231
=head3 type
229
=head3 _type
232
230
233
=cut
231
=cut
234
232
(-)a/Koha/REST/V1/ItemTypes.pm (-5 / +3 lines)
Lines 21-27 use Mojo::Base 'Mojolicious::Controller'; Link Here
21
21
22
use Koha::ItemTypes;
22
use Koha::ItemTypes;
23
23
24
use Try::Tiny;
24
use Try::Tiny qw(catch try);
25
25
26
=head1 API
26
=head1 API
27
27
Lines 35-48 sub list { Link Here
35
    my $c = shift->openapi->valid_input or return;
35
    my $c = shift->openapi->valid_input or return;
36
36
37
    return try {
37
    return try {
38
        my $itemtypes_set = Koha::ItemTypes->new;
38
        my $item_types = $c->objects->search( Koha::ItemTypes->new );
39
        my $itemtypes     = $c->objects->search( $itemtypes_set );
40
39
41
        return $c->render( status => 200, openapi => $itemtypes );
40
        return $c->render( status => 200, openapi => $item_types );
42
    } catch {
41
    } catch {
43
        $c->unhandled_exception($_);
42
        $c->unhandled_exception($_);
44
    };
43
    };
45
46
}
44
}
47
45
48
1;
46
1;
(-)a/api/v1/swagger/definitions/item_type.yaml (-2 / +2 lines)
Lines 1-7 Link Here
1
---
1
---
2
type: object
2
type: object
3
properties:
3
properties:
4
  item_type:
4
  item_type_id:
5
    type: string
5
    type: string
6
    description: Unique key, a code associated with the item type
6
    description: Unique key, a code associated with the item type
7
    readOnly: true
7
    readOnly: true
Lines 93-96 properties: Link Here
93
93
94
additionalProperties: false
94
additionalProperties: false
95
required:
95
required:
96
  - item_type
96
  - item_type_id
(-)a/t/db_dependent/api/v1/item_types.t (-5 / +3 lines)
Lines 32-38 my $builder = t::lib::TestBuilder->new; Link Here
32
my $t = Test::Mojo->new('Koha::REST::V1');
32
my $t = Test::Mojo->new('Koha::REST::V1');
33
t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 );
33
t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 );
34
34
35
subtest 'list_item_types() tests' => sub {
35
subtest 'list() tests' => sub {
36
36
37
    plan tests => 12;
37
    plan tests => 12;
38
38
Lines 109-119 subtest 'list_item_types() tests' => sub { Link Here
109
    my $unauth_userid = $patron->userid;
109
    my $unauth_userid = $patron->userid;
110
110
111
    ## Authorized user tests
111
    ## Authorized user tests
112
    # No category, 404 expected
113
    $t->get_ok("//$userid:$password@/api/v1/item_types")->status_is(200)->json_has('/0');
112
    $t->get_ok("//$userid:$password@/api/v1/item_types")->status_is(200)->json_has('/0');
114
113
115
    for my $json ( @{ $t->tx->res->json } ) {
114
    for my $json ( @{ $t->tx->res->json } ) {
116
        if ( $json->{item_type} eq 'TEST_IT' ) {
115
        if ( $json->{item_type_id} eq 'TEST_IT' ) {
117
            is( $json->{description}, 'Test item type' );
116
            is( $json->{description}, 'Test item type' );
118
            ok( !exists $json->{translated_descriptions} );
117
            ok( !exists $json->{translated_descriptions} );
119
        }
118
        }
Lines 123-129 subtest 'list_item_types() tests' => sub { Link Here
123
        ->status_is(200)->json_has('/0');
122
        ->status_is(200)->json_has('/0');
124
123
125
    for my $json ( @{ $t->tx->res->json } ) {
124
    for my $json ( @{ $t->tx->res->json } ) {
126
        if ( $json->{item_type} eq 'TEST_IT' ) {
125
        if ( $json->{item_type_id} eq 'TEST_IT' ) {
127
            is( $json->{description}, 'Test item type' );
126
            is( $json->{description}, 'Test item type' );
128
            is_deeply(
127
            is_deeply(
129
                $json->{translated_descriptions},
128
                $json->{translated_descriptions},
130
- 

Return to bug 34008