1 # This file is part of Koha.
3 # Koha is free software; you can redistribute it and/or modify it under the
4 # terms of the GNU General Public License as published by the Free Software
5 # Foundation; either version 3 of the License, or (at your option) any later
8 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
9 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
10 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12 # You should have received a copy of the GNU General Public License along
13 # with Koha; if not, see <http://www.gnu.org/licenses>.
17 use Test::More tests => 2;
22 my $t = Test::Mojo->new('Koha::REST::V1');
23 my $spec = $t->get_ok( '/api/v1/', 'Correctly fetched the spec' )->tx->res->json;
25 my $paths = $spec->{paths};
27 my @missing_additionalProperties = ();
29 foreach my $route ( keys %{$paths} ) {
30 foreach my $verb ( keys %{ $paths->{$route} } ) {
32 # p($paths->{$route}->{$verb});
35 foreach my $parameter ( @{ $paths->{$route}->{$verb}->{parameters} } ) {
36 if ( exists $parameter->{schema}
37 && exists $parameter->{schema}->{type}
38 && ref( $parameter->{schema}->{type} ) ne 'ARRAY'
39 && $parameter->{schema}->{type} eq 'object' ) {
41 # it is an object type definition
42 if ( $parameter->{name} ne 'query' # our query parameter is under-specified
43 and not exists $parameter->{schema}->{additionalProperties} ) {
44 push @missing_additionalProperties,
45 { type => 'parameter',
48 name => $parameter->{name}
55 my $responses = $paths->{$route}->{$verb}->{responses};
56 foreach my $response ( keys %{$responses} ) {
57 if ( exists $responses->{$response}->{schema}
58 && exists $responses->{$response}->{schema}->{type}
59 && ref( $responses->{$response}->{schema}->{type} ) ne 'ARRAY'
60 && $responses->{$response}->{schema}->{type} eq 'object' ) {
62 # it is an object type definition
63 if ( not exists $responses->{$response}->{schema}->{additionalProperties} ) {
64 push @missing_additionalProperties,
76 is( scalar @missing_additionalProperties, 0 )
77 or diag Dumper \@missing_additionalProperties;