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

(-)a/Koha/REST/V1/AdditionalFields.pm (+52 lines)
Line 0 Link Here
1
package Koha::REST::V1::AdditionalFields;
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::AdditionalFields;
23
24
use Try::Tiny qw( catch try );
25
26
=head1 API
27
28
=head2 Methods
29
30
=head3 list
31
32
=cut
33
34
sub list {
35
    my $c = shift->openapi->valid_input or return;
36
37
    my $tablename = $c->param('tablename');
38
39
    return try {
40
        my $additional_fields_set = Koha::AdditionalFields->new;
41
        if ($tablename) {
42
            $additional_fields_set = $additional_fields_set->search( { tablename => $tablename } );
43
        }
44
        my $additional_fields = $c->objects->search($additional_fields_set);
45
        return $c->render( status => 200, openapi => $additional_fields );
46
    } catch {
47
        $c->unhandled_exception($_);
48
    };
49
50
}
51
52
1;
(-)a/api/v1/swagger/definitions/additional_field.yaml (+35 lines)
Line 0 Link Here
1
---
2
type: object
3
properties:
4
  id:
5
    type: integer
6
    description: internally assigned additional field identifier
7
    readOnly: true
8
  tablename:
9
    description: name of the table this additional field corresponds to
10
    type: string
11
  name:
12
    description: name of the additional field
13
    type: string
14
  authorised_value_category:
15
    description: authorised value category of the additional field
16
    type:
17
      - string
18
      - "null"
19
  marcfield:
20
    description: marcfield of the additional field
21
    type: string
22
  marcfield_mode:
23
    description: marcfield mode of the additional field
24
    type: string
25
    enum:
26
      - get
27
      - set
28
  searchable:
29
    description: is the additional field searchable
30
    type: boolean
31
32
additionalProperties: false
33
required:
34
  - id
35
  - tablename
(-)a/api/v1/swagger/paths/additional_fields.yaml (+49 lines)
Line 0 Link Here
1
---
2
/additional_fields:
3
  get:
4
    x-mojo-to: AdditionalFields#list
5
    operationId: listAdditionalFields
6
    tags:
7
      - additional_fields
8
    summary: List additional fields
9
    produces:
10
      - application/json
11
    parameters:
12
      - description: filter by table name
13
        in: query
14
        name: tablename
15
        type: string
16
      - $ref: "../swagger.yaml#/parameters/match"
17
      - $ref: "../swagger.yaml#/parameters/order_by"
18
      - $ref: "../swagger.yaml#/parameters/page"
19
      - $ref: "../swagger.yaml#/parameters/per_page"
20
      - $ref: "../swagger.yaml#/parameters/q_param"
21
      - $ref: "../swagger.yaml#/parameters/q_body"
22
    responses:
23
      200:
24
        description: A list of additional_fields
25
        schema:
26
          items:
27
            $ref: "../swagger.yaml#/definitions/additional_field"
28
          type: array
29
      400:
30
        description: Bad request
31
        schema:
32
          $ref: "../swagger.yaml#/definitions/error"
33
      403:
34
        description: Access forbidden
35
        schema:
36
          $ref: "../swagger.yaml#/definitions/error"
37
      500:
38
        description: |-
39
          Internal server error. Possible `error_code` attribute values:
40
          * `internal_server_error`
41
        schema:
42
          $ref: "../swagger.yaml#/definitions/error"
43
      503:
44
        description: Under maintenance
45
        schema:
46
          $ref: "../swagger.yaml#/definitions/error"
47
    x-koha-authorization:
48
      permissions:
49
        tools: manage_additional_fields
(-)a/api/v1/swagger/swagger.yaml (-1 / +4 lines)
Lines 4-9 basePath: /api/v1 Link Here
4
definitions:
4
definitions:
5
  account_line:
5
  account_line:
6
    $ref: ./definitions/account_line.yaml
6
    $ref: ./definitions/account_line.yaml
7
  additional_field:
8
    $ref: ./definitions/additional_field.yaml
7
  advancededitormacro:
9
  advancededitormacro:
8
    $ref: ./definitions/advancededitormacro.yaml
10
    $ref: ./definitions/advancededitormacro.yaml
9
  allows_renewal:
11
  allows_renewal:
Lines 179-184 paths: Link Here
179
    $ref: "./paths/acquisitions_vendors.yaml#/~1acquisitions~1vendors~1{vendor_id}"
181
    $ref: "./paths/acquisitions_vendors.yaml#/~1acquisitions~1vendors~1{vendor_id}"
180
  "/acquisitions/vendors/{vendor_id}/issues":
182
  "/acquisitions/vendors/{vendor_id}/issues":
181
    $ref: "./paths/acquisitions_vendor_issues.yaml#/~1acquisitions~1vendors~1{vendor_id}~1issues"
183
    $ref: "./paths/acquisitions_vendor_issues.yaml#/~1acquisitions~1vendors~1{vendor_id}~1issues"
184
  /additional_fields:
185
    $ref: ./paths/additional_fields.yaml#/~1additional_fields
182
  /advanced_editor/macros:
186
  /advanced_editor/macros:
183
    $ref: ./paths/advancededitormacros.yaml#/~1advanced_editor~1macros
187
    $ref: ./paths/advancededitormacros.yaml#/~1advanced_editor~1macros
184
  /advanced_editor/macros/shared:
188
  /advanced_editor/macros/shared:
185
- 

Return to bug 35197