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

(-)a/Koha/REST/V1/Items.pm (+26 lines)
Lines 58-63 sub list { Link Here
58
    };
58
    };
59
}
59
}
60
60
61
=head3 list_public
62
63
Controller function that handles listing Koha::Item objects available to the opac
64
65
=cut
66
67
sub list_public {
68
    my $c = shift->openapi->valid_input or return;
69
70
    return try {
71
        my $patron = $c->stash('koha.user');
72
73
        my $items_set =
74
          Koha::Items->filter_by_visible_in_opac( { patron => $patron } );
75
        my $items = $c->objects->search($items_set);
76
77
        return $c->render(
78
            status  => 200,
79
            openapi => $items
80
        );
81
    }
82
    catch {
83
        $c->unhandled_exception($_);
84
    };
85
}
86
61
=head3 get
87
=head3 get
62
88
63
Controller function that handles retrieving a single Koha::Item
89
Controller function that handles retrieving a single Koha::Item
(-)a/api/v1/swagger/paths/items.yaml (+51 lines)
Lines 396-398 Link Here
396
    x-koha-authorization:
396
    x-koha-authorization:
397
      permissions:
397
      permissions:
398
        reserveforothers: place_holds
398
        reserveforothers: place_holds
399
"/public/items":
400
  get:
401
    x-mojo-to: Items#list_public
402
    operationId: listItemsPublic
403
    tags:
404
      - items
405
    summary: List items publically visible
406
    parameters:
407
      - name: external_id
408
        in: query
409
        description: Search on the item's barcode
410
        required: false
411
        type: string
412
      - $ref: "../swagger.yaml#/parameters/match"
413
      - $ref: "../swagger.yaml#/parameters/order_by"
414
      - $ref: "../swagger.yaml#/parameters/page"
415
      - $ref: "../swagger.yaml#/parameters/per_page"
416
      - $ref: "../swagger.yaml#/parameters/q_param"
417
      - $ref: "../swagger.yaml#/parameters/q_body"
418
      - $ref: "../swagger.yaml#/parameters/q_header"
419
      - $ref: "../swagger.yaml#/parameters/request_id_header"
420
    consumes:
421
      - application/json
422
    produces:
423
      - application/json
424
    responses:
425
      "200":
426
        description: A list of item
427
        schema:
428
          type: array
429
          items:
430
            $ref: "../swagger.yaml#/definitions/item"
431
      "401":
432
        description: Authentication required
433
        schema:
434
          $ref: "../swagger.yaml#/definitions/error"
435
      "403":
436
        description: Access forbidden
437
        schema:
438
          $ref: "../swagger.yaml#/definitions/error"
439
      "500":
440
        description: |
441
          Internal server error. Possible `error_code` attribute values:
442
443
          * `internal_server_error`
444
        schema:
445
          $ref: "../swagger.yaml#/definitions/error"
446
      "503":
447
        description: Under maintenance
448
        schema:
449
          $ref: "../swagger.yaml#/definitions/error"
(-)a/api/v1/swagger/swagger.yaml (-1 / +2 lines)
Lines 291-296 paths: Link Here
291
    $ref: "./paths/patrons_password.yaml#/~1patrons~1{patron_id}~1password~1expiration_date"
291
    $ref: "./paths/patrons_password.yaml#/~1patrons~1{patron_id}~1password~1expiration_date"
292
  "/public/biblios/{biblio_id}":
292
  "/public/biblios/{biblio_id}":
293
    $ref: "./paths/biblios.yaml#/~1public~1biblios~1{biblio_id}"
293
    $ref: "./paths/biblios.yaml#/~1public~1biblios~1{biblio_id}"
294
  "/public/items":
295
    $ref: "./paths/items.yaml#/~1public~1items"
294
  "/public/biblios/{biblio_id}/items":
296
  "/public/biblios/{biblio_id}/items":
295
    $ref: "./paths/biblios.yaml#/~1public~1biblios~1{biblio_id}~1items"
297
    $ref: "./paths/biblios.yaml#/~1public~1biblios~1{biblio_id}~1items"
296
  "/public/biblios/{biblio_id}/ratings":
298
  "/public/biblios/{biblio_id}/ratings":
297
- 

Return to bug 33146