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

(-)a/Koha/AuthorisedValueCategory.pm (+13 lines)
Lines 33-38 Koha::AuthorisedValueCategory - Koha AuthorisedValueCategory Object class Link Here
33
33
34
=cut
34
=cut
35
35
36
=head3 authorised_values
37
38
Returns the authorised values for this authorised value category
39
40
=cut
41
42
sub authorised_values {
43
    my ( $self ) = @_;
44
45
    my $authorised_values_rs = $self->_result->authorised_values;
46
    return Koha::AuthorisedValues->_new_from_dbic($authorised_values_rs);
47
}
48
36
=head3 delete
49
=head3 delete
37
50
38
Overridden delete method to prevent system default deletions
51
Overridden delete method to prevent system default deletions
(-)a/Koha/REST/V1/AuthorisedValueCategories.pm (+49 lines)
Line 0 Link Here
1
package Koha::REST::V1::AuthorisedValueCategories;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use Mojo::Base 'Mojolicious::Controller';
21
22
use Koha::AuthorisedValues;
23
use Koha::AuthorisedValueCategories;
24
25
use Try::Tiny;
26
27
=head1 API
28
29
=head2 Methods
30
31
=head3 list
32
33
=cut
34
35
sub list {
36
    my $c = shift->openapi->valid_input or return;
37
38
    return try {
39
        my $authorised_value_categories_set = Koha::AuthorisedValueCategories->new;
40
        my $authorised_value_categories = $c->objects->search( $authorised_value_categories_set );
41
        return $c->render( status => 200, openapi => $authorised_value_categories );
42
    }
43
    catch {
44
        $c->unhandled_exception($_);
45
    };
46
47
}
48
49
1;
(-)a/api/v1/swagger/definitions/authorised_value_category.yaml (+20 lines)
Line 0 Link Here
1
---
2
type: object
3
properties:
4
  category_name:
5
    type: string
6
    description: Unique category name primary key
7
    readOnly: true
8
  is_system:
9
    description: Is this category system or not
10
    type: boolean
11
    readOnly: true
12
  authorised_values:
13
    type: array
14
    description: This category's authorised values
15
    items:
16
      $ref: authorised_value.yaml
17
18
additionalProperties: false
19
required:
20
  - category_name
(-)a/api/v1/swagger/paths/authorised_value_categories.yaml (+65 lines)
Line 0 Link Here
1
---
2
/authorised_value_categories:
3
  get:
4
    x-mojo-to: AuthorisedValueCategories#list
5
    operationId: listAuthorisedValueCategories
6
    tags:
7
      - authorised_value_categories
8
    summary: List authorised value categories
9
    produces:
10
      - application/json
11
    parameters:
12
      - name: category_names
13
        in: query
14
        description: Case insensitive search on category names
15
        required: false
16
        type: array
17
      - name: x-koha-embed
18
        in: header
19
        required: false
20
        description: Embed list sent as a request header
21
        type: array
22
        items:
23
          type: string
24
          enum:
25
            - authorised_values
26
        collectionFormat: csv
27
      - $ref: "../swagger.yaml#/parameters/match"
28
      - $ref: "../swagger.yaml#/parameters/order_by"
29
      - $ref: "../swagger.yaml#/parameters/page"
30
      - $ref: "../swagger.yaml#/parameters/per_page"
31
      - $ref: "../swagger.yaml#/parameters/q_param"
32
      - $ref: "../swagger.yaml#/parameters/q_body"
33
      - $ref: "../swagger.yaml#/parameters/q_header"
34
    responses:
35
      200:
36
        description: A list of authorised value categories
37
        schema:
38
          items:
39
            $ref: "../swagger.yaml#/definitions/authorised_value_category"
40
          type: array
41
      400:
42
        description: Bad request
43
        schema:
44
          $ref: "../swagger.yaml#/definitions/error"
45
      403:
46
        description: Access forbidden
47
        schema:
48
          $ref: "../swagger.yaml#/definitions/error"
49
      404:
50
        description: Resource not found
51
        schema:
52
          $ref: "../swagger.yaml#/definitions/error"
53
      500:
54
        description: |-
55
          Internal server error. Possible `error_code` attribute values:
56
          * `internal_server_error`
57
        schema:
58
          $ref: "../swagger.yaml#/definitions/error"
59
      503:
60
        description: Under maintenance
61
        schema:
62
          $ref: "../swagger.yaml#/definitions/error"
63
    x-koha-authorization:
64
      permissions:
65
        catalogue: 1
(-)a/api/v1/swagger/swagger.yaml (-1 / +4 lines)
Lines 10-15 definitions: Link Here
10
    $ref: ./definitions/allows_renewal.yaml
10
    $ref: ./definitions/allows_renewal.yaml
11
  authorised_value:
11
  authorised_value:
12
    $ref: ./definitions/authorised_value.yaml
12
    $ref: ./definitions/authorised_value.yaml
13
  authorised_value_category:
14
    $ref: ./definitions/authorised_value_category.yaml
13
  identity_provider:
15
  identity_provider:
14
    "$ref": ./definitions/identity_provider.yaml
16
    "$ref": ./definitions/identity_provider.yaml
15
  identity_provider_domain:
17
  identity_provider_domain:
Lines 153-158 paths: Link Here
153
    $ref: paths/auth.yaml#/~1auth~1identity_providers~1{identity_provider_id}~1domains
155
    $ref: paths/auth.yaml#/~1auth~1identity_providers~1{identity_provider_id}~1domains
154
  "/auth/identity_providers/{identity_provider_id}/domains/{identity_provider_domain_id}":
156
  "/auth/identity_providers/{identity_provider_id}/domains/{identity_provider_domain_id}":
155
    $ref: paths/auth.yaml#/~1auth~1identity_providers~1{identity_provider_id}~1domains~1{identity_provider_domain_id}
157
    $ref: paths/auth.yaml#/~1auth~1identity_providers~1{identity_provider_id}~1domains~1{identity_provider_domain_id}
158
  /authorised_value_categories:
159
    $ref: paths/authorised_value_categories.yaml#/~1authorised_value_categories
156
  "/authorised_value_categories/{authorised_value_category_name}/values":
160
  "/authorised_value_categories/{authorised_value_category_name}/values":
157
    $ref: "./paths/authorised_values.yaml#/~1authorised_value_categories~1{authorised_value_category_name}~1values"
161
    $ref: "./paths/authorised_values.yaml#/~1authorised_value_categories~1{authorised_value_category_name}~1values"
158
  "/biblios/{biblio_id}":
162
  "/biblios/{biblio_id}":
159
- 

Return to bug 32997