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 ( not exists $parameter->{schema}->{additionalProperties} ) {
43 push @missing_additionalProperties,
44 { type => 'parameter',
47 name => $parameter->{name}
54 my $responses = $paths->{$route}->{$verb}->{responses};
55 foreach my $response ( keys %{$responses} ) {
56 if ( exists $responses->{$response}->{schema}
57 && exists $responses->{$response}->{schema}->{type}
58 && ref( $responses->{$response}->{schema}->{type} ) ne 'ARRAY'
59 && $responses->{$response}->{schema}->{type} eq 'object' ) {
61 # it is an object type definition
62 if ( not exists $responses->{$response}->{schema}->{additionalProperties} ) {
63 push @missing_additionalProperties,
75 is( scalar @missing_additionalProperties, 0 )
76 or diag Dumper \@missing_additionalProperties;