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 (+60 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: x-koha-embed
13
        in: header
14
        required: false
15
        description: Embed list sent as a request header
16
        type: array
17
        items:
18
          type: string
19
          enum:
20
            - authorised_values
21
        collectionFormat: csv
22
      - $ref: "../swagger.yaml#/parameters/match"
23
      - $ref: "../swagger.yaml#/parameters/order_by"
24
      - $ref: "../swagger.yaml#/parameters/page"
25
      - $ref: "../swagger.yaml#/parameters/per_page"
26
      - $ref: "../swagger.yaml#/parameters/q_param"
27
      - $ref: "../swagger.yaml#/parameters/q_body"
28
      - $ref: "../swagger.yaml#/parameters/q_header"
29
    responses:
30
      200:
31
        description: A list of authorised value categories
32
        schema:
33
          items:
34
            $ref: "../swagger.yaml#/definitions/authorised_value_category"
35
          type: array
36
      400:
37
        description: Bad request
38
        schema:
39
          $ref: "../swagger.yaml#/definitions/error"
40
      403:
41
        description: Access forbidden
42
        schema:
43
          $ref: "../swagger.yaml#/definitions/error"
44
      404:
45
        description: Resource not found
46
        schema:
47
          $ref: "../swagger.yaml#/definitions/error"
48
      500:
49
        description: |-
50
          Internal server error. Possible `error_code` attribute values:
51
          * `internal_server_error`
52
        schema:
53
          $ref: "../swagger.yaml#/definitions/error"
54
      503:
55
        description: Under maintenance
56
        schema:
57
          $ref: "../swagger.yaml#/definitions/error"
58
    x-koha-authorization:
59
      permissions:
60
        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 141-146 paths: Link Here
141
    $ref: paths/auth.yaml#/~1auth~1identity_providers~1{identity_provider_id}~1domains
143
    $ref: paths/auth.yaml#/~1auth~1identity_providers~1{identity_provider_id}~1domains
142
  "/auth/identity_providers/{identity_provider_id}/domains/{identity_provider_domain_id}":
144
  "/auth/identity_providers/{identity_provider_id}/domains/{identity_provider_domain_id}":
143
    $ref: paths/auth.yaml#/~1auth~1identity_providers~1{identity_provider_id}~1domains~1{identity_provider_domain_id}
145
    $ref: paths/auth.yaml#/~1auth~1identity_providers~1{identity_provider_id}~1domains~1{identity_provider_domain_id}
146
  /authorised_value_categories:
147
    $ref: paths/authorised_value_categories.yaml#/~1authorised_value_categories
144
  "/authorised_value_categories/{authorised_value_category_name}/values":
148
  "/authorised_value_categories/{authorised_value_category_name}/values":
145
    $ref: "./paths/authorised_values.yaml#/~1authorised_value_categories~1{authorised_value_category_name}~1values"
149
    $ref: "./paths/authorised_values.yaml#/~1authorised_value_categories~1{authorised_value_category_name}~1values"
146
  "/biblios/{biblio_id}":
150
  "/biblios/{biblio_id}":
147
- 

Return to bug 32997