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

(-)a/Koha/REST/V1/Biblios.pm (+37 lines)
Lines 268-271 sub get_items { Link Here
268
    };
268
    };
269
}
269
}
270
270
271
=head3 get_items_public
272
273
Controller function that handles retrieving biblio's items, for unprivileged
274
access.
275
276
=cut
277
278
sub get_items_public {
279
    my $c = shift->openapi->valid_input or return;
280
281
    my $biblio = Koha::Biblios->find( { biblionumber => $c->validation->param('biblio_id') }, { prefetch => ['items'] } );
282
283
    unless ( $biblio ) {
284
        return $c->render(
285
            status  => 404,
286
            openapi => {
287
                error => "Object not found."
288
            }
289
        );
290
    }
291
292
    return try {
293
294
        my $patron = $c->stash('koha.user');
295
296
        my $items_rs = $biblio->items->filter_by_visible_in_opac({ patron => $patron });
297
        my $items    = $c->objects->search( $items_rs );
298
        return $c->render(
299
            status  => 200,
300
            openapi => $items
301
        );
302
    }
303
    catch {
304
        $c->unhandled_exception($_);
305
    };
306
}
307
271
1;
308
1;
(-)a/api/v1/swagger/paths.json (+3 lines)
Lines 128-133 Link Here
128
  "/public/biblios/{biblio_id}": {
128
  "/public/biblios/{biblio_id}": {
129
    "$ref": "paths/biblios.json#/~1public~1biblios~1{biblio_id}"
129
    "$ref": "paths/biblios.json#/~1public~1biblios~1{biblio_id}"
130
  },
130
  },
131
  "/public/biblios/{biblio_id}/items": {
132
    "$ref": "paths/biblios.json#/~1public~1biblios~1{biblio_id}~1items"
133
  },
131
  "/public/patrons/{patron_id}/password": {
134
  "/public/patrons/{patron_id}/password": {
132
    "$ref": "paths/public_patrons.json#/~1public~1patrons~1{patron_id}~1password"
135
    "$ref": "paths/public_patrons.json#/~1public~1patrons~1{patron_id}~1password"
133
  },
136
  },
(-)a/api/v1/swagger/paths/biblios.json (-1 / +93 lines)
Lines 296-300 Link Here
296
        }
296
        }
297
      }
297
      }
298
    }
298
    }
299
  },
300
  "/public/biblios/{biblio_id}/items": {
301
    "get": {
302
      "x-mojo-to": "Biblios#get_items_public",
303
      "operationId": "getBiblioItemsPublic",
304
      "tags": [
305
        "biblios",
306
        "items"
307
      ],
308
      "parameters": [
309
        {
310
          "$ref": "../parameters.json#/biblio_id_pp"
311
        },
312
        {
313
          "$ref": "../parameters.json#/match"
314
        },
315
        {
316
          "$ref": "../parameters.json#/order_by"
317
        },
318
        {
319
          "$ref": "../parameters.json#/page"
320
        },
321
        {
322
          "$ref": "../parameters.json#/per_page"
323
        },
324
        {
325
          "$ref": "../parameters.json#/q_param"
326
        },
327
        {
328
          "$ref": "../parameters.json#/q_body"
329
        },
330
        {
331
          "$ref": "../parameters.json#/q_header"
332
        }
333
      ],
334
      "consumes": [
335
        "application/json"
336
      ],
337
      "produces": [
338
        "application/json"
339
      ],
340
      "responses": {
341
        "200": {
342
          "description": "A list of the items attached to the record",
343
          "schema": {
344
            "type": "array",
345
            "items": {
346
              "$ref": "../definitions.json#/item"
347
            }
348
          }
349
        },
350
        "401": {
351
          "description": "Authentication required",
352
          "schema": {
353
            "$ref": "../definitions.json#/error"
354
          }
355
        },
356
        "403": {
357
          "description": "Access forbidden",
358
          "schema": {
359
            "$ref": "../definitions.json#/error"
360
          }
361
        },
362
        "404": {
363
          "description": "Biblio not found",
364
          "schema": {
365
            "$ref": "../definitions.json#/error"
366
          }
367
        },
368
        "406": {
369
          "description": "Not acceptable",
370
          "schema": {
371
            "type": "array",
372
            "description": "Accepted content-types",
373
            "items": {
374
                "type": "string"
375
            }
376
          }
377
        },
378
        "500": {
379
          "description": "Internal server error",
380
          "schema": {
381
            "$ref": "../definitions.json#/error"
382
          }
383
        },
384
        "503": {
385
          "description": "Under maintenance",
386
          "schema": {
387
            "$ref": "../definitions.json#/error"
388
          }
389
        }
390
      }
391
    }
299
  }
392
  }
300
}
393
}
301
- 

Return to bug 27358