]> git.koha-community.org Git - koha.git/commit
Bug 13799: RESTful API with Mojolicious and Swagger2
authorJulian Maurice <julian.maurice@biblibre.com>
Wed, 4 Mar 2015 15:46:33 +0000 (16:46 +0100)
committerTomas Cohen Arazi <tomascohen@theke.io>
Wed, 4 Nov 2015 16:47:32 +0000 (13:47 -0300)
commitc83cd774117f808aab27ece79fc31c9c44d4fffc
treef90c7b868b9b7786177fb19749ec59031083a2cc
parent314f3e22d969b05ffd0590153707fd0c673987be
Bug 13799: RESTful API with Mojolicious and Swagger2

Actual routes are:
  /borrowers
    Return a list of all borrowers in Koha

  /borrowers/{borrowernumber}
    Return the borrower identified by {borrowernumber}
    (eg. /borrowers/1)

There is a test file you can run with:
  $ prove t/db_dependent/rest/borrowers.t

All API stuff is in /api/v1 (except Perl modules)
So we have:
  /api/v1/script.cgi     CGI script
  /api/v1/swagger.json   Swagger specification

Change both OPAC and Intranet VirtualHosts to access the API,
so we have:
  http://OPAC/api/v1/swagger.json   Swagger specification
  http://OPAC/api/v1/{path}         API endpoint
  http://INTRANET/api/v1/swagger.json   Swagger specification
  http://INTRANET/api/v1/{path}         API endpoint

Add a (disabled) virtual host in Apache configuration api.HOSTNAME,
so we have:
  http://api.HOSTNAME/api/v1/swagger.json   Swagger specification
  http://api.HOSTNAME/api/v1/{path}         API endpoint

Add 'unblessed' subroutines to both Koha::Objects and Koha::Object to be
able to pass it to Mojolicious

Test plan:
  1/ Install Perl modules Mojolicious and Swagger2
  2/ perl Makefile.PL
  3/ make && make install
  4/ Change etc/koha-httpd.conf and copy it to the right place if needed
  5/ Reload Apache
  6/ Check that http://(OPAC|INTRANET)/api/v1/borrowers and
     http://(OPAC|INTRANET)/api/v1/borrowers/{borrowernumber} works

Optionally, you could verify that http://(OPAC|INTRANET)/vX/borrowers
(where X is an integer greater than 1) returns a 404 error

Signed-off-by: Alex Arnaud <alex.arnaud@biblibre.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
C4/Installer/PerlDependencies.pm
Koha/Object.pm
Koha/Objects.pm
Koha/REST/V1.pm [new file with mode: 0644]
Koha/REST/V1/Borrowers.pm [new file with mode: 0644]
api/v1/app.pl [new file with mode: 0755]
api/v1/swagger.json [new file with mode: 0644]
etc/koha-httpd.conf
t/db_dependent/api/v1/borrowers.t [new file with mode: 0644]