Bugzilla – Attachment 66811 Details for
Bug 18137
Migrate from Mojolicious::Plugin::Swagger2 to Mojolicious::Plugin::OpenAPI
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18137: Make /patrons Mojolicious::Plugin::OpenAPI compatible
Bug-18137-Make-patrons-MojoliciousPluginOpenAPI-co.patch (text/plain), 4.51 KB, created by
Tomás Cohen Arazi (tcohen)
on 2017-09-04 13:55:48 UTC
(
hide
)
Description:
Bug 18137: Make /patrons Mojolicious::Plugin::OpenAPI compatible
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2017-09-04 13:55:48 UTC
Size:
4.51 KB
patch
obsolete
>From 1aaabe71a1166c223d8d02fcf345a7e6e1534106 Mon Sep 17 00:00:00 2001 >From: Lari Taskula <lari.taskula@jns.fi> >Date: Fri, 17 Feb 2017 14:59:24 +0200 >Subject: [PATCH] Bug 18137: Make /patrons Mojolicious::Plugin::OpenAPI > compatible > >Also: >- adding some missing and new response definitions into Swagger spec. >- fixing failing test due to Bug 17932's change of boolean values > >To test: >1. prove t/db_dependent/api/v1/patrons.t > >Signed-off-by: Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/REST/V1/Patron.pm | 17 +++++++---------- > api/v1/swagger/paths/patrons.json | 38 ++++++++++++++++++++++++++++++++++++++ > t/db_dependent/api/v1/patrons.t | 2 +- > 3 files changed, 46 insertions(+), 11 deletions(-) > >diff --git a/Koha/REST/V1/Patron.pm b/Koha/REST/V1/Patron.pm >index 477980e0fa..7cc7bedffc 100644 >--- a/Koha/REST/V1/Patron.pm >+++ b/Koha/REST/V1/Patron.pm >@@ -22,26 +22,23 @@ use Mojo::Base 'Mojolicious::Controller'; > use Koha::Patrons; > > sub list { >- my ($c, $args, $cb) = @_; >- >- my $user = $c->stash('koha.user'); >+ my $c = shift->openapi->valid_input or return; > > my $patrons = Koha::Patrons->search; > >- $c->$cb($patrons, 200); >+ return $c->render(status => 200, openapi => $patrons); > } > > sub get { >- my ($c, $args, $cb) = @_; >- >- my $user = $c->stash('koha.user'); >+ my $c = shift->openapi->valid_input or return; > >- my $patron = Koha::Patrons->find($args->{borrowernumber}); >+ my $borrowernumber = $c->validation->param('borrowernumber'); >+ my $patron = Koha::Patrons->find($borrowernumber); > unless ($patron) { >- return $c->$cb({error => "Patron not found"}, 404); >+ return $c->render(status => 404, openapi => { error => "Patron not found." }); > } > >- return $c->$cb($patron, 200); >+ return $c->render(status => 200, openapi => $patron); > } > > 1; >diff --git a/api/v1/swagger/paths/patrons.json b/api/v1/swagger/paths/patrons.json >index 67632e1bbc..204ccdf10b 100644 >--- a/api/v1/swagger/paths/patrons.json >+++ b/api/v1/swagger/paths/patrons.json >@@ -1,6 +1,7 @@ > { > "/patrons": { > "get": { >+ "x-mojo-to": "Patron#list", > "operationId": "listPatrons", > "tags": ["patrons"], > "produces": [ >@@ -16,11 +17,29 @@ > } > } > }, >+ "401": { >+ "description": "Authentication required", >+ "schema": { >+ "$ref": "../definitions.json#/error" >+ } >+ }, > "403": { > "description": "Access forbidden", > "schema": { > "$ref": "../definitions.json#/error" > } >+ }, >+ "500": { >+ "description": "Internal server error", >+ "schema": { >+ "$ref": "../definitions.json#/error" >+ } >+ }, >+ "503": { >+ "description": "Under maintenance", >+ "schema": { >+ "$ref": "../definitions.json#/error" >+ } > } > }, > "x-koha-authorization": { >@@ -32,6 +51,7 @@ > }, > "/patrons/{borrowernumber}": { > "get": { >+ "x-mojo-to": "Patron#get", > "operationId": "getPatron", > "tags": ["patrons"], > "parameters": [{ >@@ -48,6 +68,12 @@ > "$ref": "../definitions.json#/patron" > } > }, >+ "401": { >+ "description": "Authentication required", >+ "schema": { >+ "$ref": "../definitions.json#/error" >+ } >+ }, > "403": { > "description": "Access forbidden", > "schema": { >@@ -59,6 +85,18 @@ > "schema": { > "$ref": "../definitions.json#/error" > } >+ }, >+ "500": { >+ "description": "Internal server error", >+ "schema": { >+ "$ref": "../definitions.json#/error" >+ } >+ }, >+ "503": { >+ "description": "Under maintenance", >+ "schema": { >+ "$ref": "../definitions.json#/error" >+ } > } > }, > "x-koha-authorization": { >diff --git a/t/db_dependent/api/v1/patrons.t b/t/db_dependent/api/v1/patrons.t >index 909e36e93e..a8579db581 100644 >--- a/t/db_dependent/api/v1/patrons.t >+++ b/t/db_dependent/api/v1/patrons.t >@@ -133,6 +133,6 @@ $t->request_ok($tx) > ->status_is(200) > ->json_is('/borrowernumber' => $borrower->{ borrowernumber }) > ->json_is('/surname' => $borrower->{ surname }) >- ->json_is('/lost' => 1 ); >+ ->json_is('/lost' => Mojo::JSON->true ); > > $schema->storage->txn_rollback; >-- >2.14.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 18137
:
60490
|
60491
|
60492
|
60493
|
60494
|
60495
|
60533
|
60837
|
60838
|
60839
|
60840
|
60841
|
60842
|
60843
|
60866
|
60867
|
61163
|
61166
|
62780
|
62781
|
62782
|
62783
|
62784
|
62785
|
62786
|
62787
|
62788
|
62789
|
62816
|
63025
|
63026
|
63027
|
63028
|
63029
|
63030
|
63031
|
63032
|
63033
|
63034
|
63177
|
63178
|
63179
|
63180
|
63181
|
63182
|
63183
|
63184
|
63185
|
63186
|
63187
|
63188
|
63189
|
63190
|
63191
|
63192
|
63193
|
63194
|
63195
|
63196
|
63283
|
65106
|
65107
|
65108
|
65109
|
65110
|
65111
|
65112
|
65113
|
65114
|
65115
|
65404
|
65713
|
65714
|
66802
|
66803
|
66804
|
66805
|
66806
|
66807
|
66808
|
66809
|
66810
| 66811 |
66812
|
66813
|
66814
|
66815
|
66816
|
66817
|
66818
|
66819