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

(-)a/Koha/Item.pm (+30 lines)
Lines 1183-1188 sub _set_found_trigger { Link Here
1183
    return $self;
1183
    return $self;
1184
}
1184
}
1185
1185
1186
=head3 public_read_list
1187
1188
This method returns the list of publicly readable database fields for both API and UI output purposes
1189
1190
=cut
1191
1192
sub public_read_list {
1193
    return [
1194
        'itemnumber',               'biblionumber',
1195
        'barcode',                  'dateaccessioned',
1196
        'booksellerid',             'homebranch',
1197
        'price',                    'replacementprice',
1198
        'replacementpricedate',     'datelastborrowed',
1199
        'datelastseen',             'stack',
1200
        'notforloan',               'damaged',
1201
        'damaged_on',               'itemlost',
1202
        'itemlost_on',              'withdrawn',
1203
        'withdrawn_on',             'itemcallnumber',
1204
        'coded_location_qualifier', 'renewals',
1205
        'restricted',               'itemnotes',
1206
        'holdingbranch',            'timestamp',
1207
        'location',                 'permanent_location',
1208
        'cn_source',                'cn_sort',
1209
        'ccode',                    'materials',
1210
        'uri',                      'itype',
1211
        'enumchron',                'copynumber',
1212
        'stocknumber',              'new_status'
1213
    ];
1214
}
1215
1186
=head3 to_api_mapping
1216
=head3 to_api_mapping
1187
1217
1188
This method returns the mapping for representing a Koha::Item object
1218
This method returns the mapping for representing a Koha::Item object
(-)a/Koha/REST/V1/Biblios.pm (+37 lines)
Lines 340-343 sub pickup_locations { Link Here
340
    };
340
    };
341
}
341
}
342
342
343
=head3 get_items_public
344
345
Controller function that handles retrieving biblio's items, for unprivileged
346
access.
347
348
=cut
349
350
sub get_items_public {
351
    my $c = shift->openapi->valid_input or return;
352
353
    my $biblio = Koha::Biblios->find( { biblionumber => $c->validation->param('biblio_id') }, { prefetch => ['items'] } );
354
355
    unless ( $biblio ) {
356
        return $c->render(
357
            status  => 404,
358
            openapi => {
359
                error => "Object not found."
360
            }
361
        );
362
    }
363
364
    return try {
365
366
        my $patron = $c->stash('koha.user');
367
368
        my $items_rs = $biblio->items->filter_by_visible_in_opac({ patron => $patron });
369
        my $items    = $c->objects->search( $items_rs );
370
        return $c->render(
371
            status  => 200,
372
            openapi => $items
373
        );
374
    }
375
    catch {
376
        $c->unhandled_exception($_);
377
    };
378
}
379
343
1;
380
1;
(-)a/api/v1/swagger/paths.json (+3 lines)
Lines 164-169 Link Here
164
  "/public/biblios/{biblio_id}": {
164
  "/public/biblios/{biblio_id}": {
165
    "$ref": "paths/biblios.json#/~1public~1biblios~1{biblio_id}"
165
    "$ref": "paths/biblios.json#/~1public~1biblios~1{biblio_id}"
166
  },
166
  },
167
  "/public/biblios/{biblio_id}/items": {
168
    "$ref": "paths/biblios.json#/~1public~1biblios~1{biblio_id}~1items"
169
  },
167
  "/public/libraries": {
170
  "/public/libraries": {
168
    "$ref": "paths/libraries.json#/~1public~1libraries"
171
    "$ref": "paths/libraries.json#/~1public~1libraries"
169
  },
172
  },
(-)a/api/v1/swagger/paths/biblios.json (-1 / +93 lines)
Lines 396-400 Link Here
396
        }
396
        }
397
      }
397
      }
398
    }
398
    }
399
  },
400
  "/public/biblios/{biblio_id}/items": {
401
    "get": {
402
      "x-mojo-to": "Biblios#get_items_public",
403
      "operationId": "getBiblioItemsPublic",
404
      "tags": [
405
        "biblios",
406
        "items"
407
      ],
408
      "parameters": [
409
        {
410
          "$ref": "../parameters.json#/biblio_id_pp"
411
        },
412
        {
413
          "$ref": "../parameters.json#/match"
414
        },
415
        {
416
          "$ref": "../parameters.json#/order_by"
417
        },
418
        {
419
          "$ref": "../parameters.json#/page"
420
        },
421
        {
422
          "$ref": "../parameters.json#/per_page"
423
        },
424
        {
425
          "$ref": "../parameters.json#/q_param"
426
        },
427
        {
428
          "$ref": "../parameters.json#/q_body"
429
        },
430
        {
431
          "$ref": "../parameters.json#/q_header"
432
        }
433
      ],
434
      "consumes": [
435
        "application/json"
436
      ],
437
      "produces": [
438
        "application/json"
439
      ],
440
      "responses": {
441
        "200": {
442
          "description": "A list of the items attached to the record",
443
          "schema": {
444
            "type": "array",
445
            "items": {
446
              "$ref": "../definitions.json#/item"
447
            }
448
          }
449
        },
450
        "401": {
451
          "description": "Authentication required",
452
          "schema": {
453
            "$ref": "../definitions.json#/error"
454
          }
455
        },
456
        "403": {
457
          "description": "Access forbidden",
458
          "schema": {
459
            "$ref": "../definitions.json#/error"
460
          }
461
        },
462
        "404": {
463
          "description": "Biblio not found",
464
          "schema": {
465
            "$ref": "../definitions.json#/error"
466
          }
467
        },
468
        "406": {
469
          "description": "Not acceptable",
470
          "schema": {
471
            "type": "array",
472
            "description": "Accepted content-types",
473
            "items": {
474
                "type": "string"
475
            }
476
          }
477
        },
478
        "500": {
479
          "description": "Internal server error",
480
          "schema": {
481
            "$ref": "../definitions.json#/error"
482
          }
483
        },
484
        "503": {
485
          "description": "Under maintenance",
486
          "schema": {
487
            "$ref": "../definitions.json#/error"
488
          }
489
        }
490
      }
491
    }
399
  }
492
  }
400
}
493
}
401
- 

Return to bug 27358