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

(-)a/Koha/REST/V1/Patrons/Image.pm (-7 / +3 lines)
Lines 40-46 Controller method that gets a patron's image Link Here
40
=cut
40
=cut
41
41
42
sub get {
42
sub get {
43
44
    my $c = shift->openapi->valid_input or return;
43
    my $c = shift->openapi->valid_input or return;
45
44
46
    my $patron = Koha::Patrons->find( $c->param('patron_id') );
45
    my $patron = Koha::Patrons->find( $c->param('patron_id') );
Lines 57-74 sub get { Link Here
57
56
58
        unless ($image) {
57
        unless ($image) {
59
            return $c->render(
58
            return $c->render(
60
                status => 404,
59
                status  => 404,
61
                openapi => { error => "Patron image not found." }
60
                openapi => { error => "Patron image not found." }
62
            );
61
            );
63
        }
62
        }
64
63
65
        return $c->render(
64
        return $c->render(
66
            status => 200,
65
            status => 200,
67
            openapi => {
66
            format => "png",              # currently all patron images are converted to png upon upload
68
                patron_id => $image->borrowernumber,
67
            data   => $image->imagefile
69
                mimetype => $image->mimetype,
70
                imagefile => encode_base64($image->imagefile)
71
            }
72
        );
68
        );
73
    } catch {
69
    } catch {
74
        $c->unhandled_exception($_);
70
        $c->unhandled_exception($_);
(-)a/api/v1/swagger/definitions/patron_image.yaml (-14 lines)
Lines 1-14 Link Here
1
---
2
type: object
3
properties:
4
  patron_id:
5
    type: integer
6
    description: Internal patron identifier
7
  mimetype:
8
    type: string
9
    description: Patron image mimetype
10
  imagefile:
11
    type: string
12
    description: Patron image raw data
13
required:
14
  - patron_id
(-)a/api/v1/swagger/paths/patrons_image.yaml (-4 / +2 lines)
Lines 1-5 Link Here
1
---
1
---
2
"/patrons/{patron_id}/image":
2
"/patrons/{patron_id}/default_image":
3
  get:
3
  get:
4
    x-mojo-to: Patrons::Image#get
4
    x-mojo-to: Patrons::Image#get
5
    operationId: getPatronImage
5
    operationId: getPatronImage
Lines 9-20 Link Here
9
    parameters:
9
    parameters:
10
      - $ref: "../swagger.yaml#/parameters/patron_id_pp"
10
      - $ref: "../swagger.yaml#/parameters/patron_id_pp"
11
    produces:
11
    produces:
12
      - application/json
12
      - image/png
13
    responses:
13
    responses:
14
      "200":
14
      "200":
15
        description: Patron's image
15
        description: Patron's image
16
        schema:
17
          $ref: "../swagger.yaml#/definitions/patron_image"
18
      "401":
16
      "401":
19
        description: Authentication required
17
        description: Authentication required
20
        schema:
18
        schema:
(-)a/api/v1/swagger/swagger.yaml (-5 / +2 lines)
Lines 130-137 definitions: Link Here
130
    $ref: ./definitions/patron_balance.yaml
130
    $ref: ./definitions/patron_balance.yaml
131
  patron_extended_attribute:
131
  patron_extended_attribute:
132
    $ref: ./definitions/patron_extended_attribute.yaml
132
    $ref: ./definitions/patron_extended_attribute.yaml
133
  patron_image:
134
    $ref: ./definitions/patron_image.yaml
135
  preservation_config:
133
  preservation_config:
136
    $ref: ./definitions/preservation_config.yaml
134
    $ref: ./definitions/preservation_config.yaml
137
  preservation_train:
135
  preservation_train:
Lines 425-432 paths: Link Here
425
    $ref: "./paths/patrons_extended_attributes.yaml#/~1patrons~1{patron_id}~1extended_attributes~1{extended_attribute_id}"
423
    $ref: "./paths/patrons_extended_attributes.yaml#/~1patrons~1{patron_id}~1extended_attributes~1{extended_attribute_id}"
426
  "/patrons/{patron_id}/holds":
424
  "/patrons/{patron_id}/holds":
427
    $ref: "./paths/patrons_holds.yaml#/~1patrons~1{patron_id}~1holds"
425
    $ref: "./paths/patrons_holds.yaml#/~1patrons~1{patron_id}~1holds"
428
  "/patrons/{patron_id}/image":
426
  "/patrons/{patron_id}/default_image":
429
    $ref: "./paths/patrons_image.yaml#/~1patrons~1{patron_id}~1image"
427
    $ref: "./paths/patrons_image.yaml#/~1patrons~1{patron_id}~1default_image"
430
  "/patrons/{patron_id}/password":
428
  "/patrons/{patron_id}/password":
431
    $ref: "./paths/patrons_password.yaml#/~1patrons~1{patron_id}~1password"
429
    $ref: "./paths/patrons_password.yaml#/~1patrons~1{patron_id}~1password"
432
  "/patrons/{patron_id}/password/expiration_date":
430
  "/patrons/{patron_id}/password/expiration_date":
433
- 

Return to bug 35797