Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package perl-JSON-Validator for 
openSUSE:Factory checked in at 2021-04-29 22:46:52
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/perl-JSON-Validator (Old)
 and      /work/SRC/openSUSE:Factory/.perl-JSON-Validator.new.1947 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "perl-JSON-Validator"

Thu Apr 29 22:46:52 2021 rev:31 rq:889346 version:4.17

Changes:
--------
--- /work/SRC/openSUSE:Factory/perl-JSON-Validator/perl-JSON-Validator.changes  
2021-04-12 17:10:34.242578673 +0200
+++ 
/work/SRC/openSUSE:Factory/.perl-JSON-Validator.new.1947/perl-JSON-Validator.changes
        2021-04-29 22:53:33.397848722 +0200
@@ -1,0 +2,11 @@
+Thu Apr 29 03:07:08 UTC 2021 - Tina M??ller <[email protected]>
+
+- updated to 4.17
+   see /usr/share/doc/packages/perl-JSON-Validator/Changes
+
+  4.17 2021-04-28T11:30:56+0900
+   - Add add_default_response() to OpenAPIv2 and OpenAPIv3
+   - Add base_url() to OpenAPIv2 and OpenAPIv3
+   - Fix validating "nullable" for "array" and "object"
+
+-------------------------------------------------------------------

Old:
----
  JSON-Validator-4.16.tar.gz

New:
----
  JSON-Validator-4.17.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ perl-JSON-Validator.spec ++++++
--- /var/tmp/diff_new_pack.G6eXno/_old  2021-04-29 22:53:33.757847063 +0200
+++ /var/tmp/diff_new_pack.G6eXno/_new  2021-04-29 22:53:33.761847045 +0200
@@ -18,7 +18,7 @@
 
 %define cpan_name JSON-Validator
 Name:           perl-JSON-Validator
-Version:        4.16
+Version:        4.17
 Release:        0
 Summary:        Validate data against a JSON schema
 License:        Artistic-2.0
@@ -33,11 +33,9 @@
 BuildRequires:  perl(Test::Deep)
 BuildRequires:  perl(Test::More) >= 1.30
 BuildRequires:  perl(YAML::PP) >= 0.020
-BuildRequires:  perl(YAML::XS) >= 0.67
 Requires:       perl(List::Util) >= 1.45
 Requires:       perl(Mojolicious) >= 7.28
 Requires:       perl(YAML::PP) >= 0.020
-Requires:       perl(YAML::XS) >= 0.67
 %{perl_requires}
 
 %description

++++++ JSON-Validator-4.16.tar.gz -> JSON-Validator-4.17.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/JSON-Validator-4.16/Changes 
new/JSON-Validator-4.17/Changes
--- old/JSON-Validator-4.16/Changes     2021-03-24 00:57:46.000000000 +0100
+++ new/JSON-Validator-4.17/Changes     2021-04-28 04:30:56.000000000 +0200
@@ -1,5 +1,10 @@
 Revision history for perl distribution JSON-Validator
 
+4.17 2021-04-28T11:30:56+0900
+ - Add add_default_response() to OpenAPIv2 and OpenAPIv3
+ - Add base_url() to OpenAPIv2 and OpenAPIv3
+ - Fix validating "nullable" for "array" and "object"
+
 4.16 2021-03-24T08:57:46+0900
  - Fix handling OpenAPIv2 "responses" $ref when bundling
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/JSON-Validator-4.16/META.json 
new/JSON-Validator-4.17/META.json
--- old/JSON-Validator-4.16/META.json   2021-03-24 00:57:47.000000000 +0100
+++ new/JSON-Validator-4.17/META.json   2021-04-28 04:30:58.000000000 +0200
@@ -36,7 +36,7 @@
          "requires" : {
             "List::Util" : "1.45",
             "Mojolicious" : "7.28",
-            "YAML::XS" : "0.67",
+            "YAML::PP" : "0.020",
             "perl" : "5.010001"
          }
       },
@@ -63,6 +63,6 @@
       },
       "x_IRC" : "irc://irc.freenode.net/#perl-openapi"
    },
-   "version" : "4.16",
+   "version" : "4.17",
    "x_serialization_backend" : "JSON::PP version 4.04"
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/JSON-Validator-4.16/META.yml 
new/JSON-Validator-4.17/META.yml
--- old/JSON-Validator-4.16/META.yml    2021-03-24 00:57:47.000000000 +0100
+++ new/JSON-Validator-4.17/META.yml    2021-04-28 04:30:57.000000000 +0200
@@ -24,7 +24,7 @@
 requires:
   List::Util: '1.45'
   Mojolicious: '7.28'
-  YAML::XS: '0.67'
+  YAML::PP: '0.020'
   perl: '5.010001'
 resources:
   IRC: irc://irc.freenode.net/#perl-openapi
@@ -32,5 +32,5 @@
   homepage: https://mojolicious.org
   license: http://www.opensource.org/licenses/artistic-license-2.0
   repository: https://github.com/mojolicious/json-validator.git
-version: '4.16'
+version: '4.17'
 x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/JSON-Validator-4.16/lib/JSON/Validator/Schema/OpenAPIv2.pm 
new/JSON-Validator-4.17/lib/JSON/Validator/Schema/OpenAPIv2.pm
--- old/JSON-Validator-4.16/lib/JSON/Validator/Schema/OpenAPIv2.pm      
2021-03-24 00:57:32.000000000 +0100
+++ new/JSON-Validator-4.17/lib/JSON/Validator/Schema/OpenAPIv2.pm      
2021-04-28 03:40:51.000000000 +0200
@@ -1,6 +1,7 @@
 package JSON::Validator::Schema::OpenAPIv2;
 use Mojo::Base 'JSON::Validator::Schema::Draft4';
 
+use JSON::Validator::Ref;
 use JSON::Validator::Util qw(E data_type negotiate_content_type schema_type);
 use Mojo::Collection;
 
@@ -15,6 +16,22 @@
 has moniker       => 'openapiv2';
 has specification => 'http://swagger.io/v2/schema.json';
 
+sub add_default_response {
+  my ($self, $params) = ($_[0], shift->_params_for_add_default_response(@_));
+
+  my $definitions = $self->data->{definitions}      ||= {};
+  my $ref         = $definitions->{$params->{name}} ||= $params->{schema};
+  my %schema      = ('$ref' => "#/definitions/$params->{name}");
+  tie %schema, 'JSON::Validator::Ref', $ref, $schema{'$ref'}, $schema{'$ref'};
+
+  for my $route ($self->routes->each) {
+    my $op = $self->get([paths => @$route{qw(path method)}]);
+    $op->{responses}{$_} ||= {description => $params->{description}, schema => 
\%schema} for @{$params->{status}};
+  }
+
+  return $self;
+}
+
 sub allow_invalid_ref {
   my $self = shift;
   return $self->{allow_invalid_ref} || 0 unless @_;
@@ -26,6 +43,28 @@
   return $self;
 }
 
+sub base_url {
+  my ($self, $url) = @_;
+  my $spec = $self->data;
+
+  # Get
+  unless ($url) {
+    $url = Mojo::URL->new;
+    $url->host($spec->{host}) if $spec->{host};
+    $url->path($spec->{basePath} || '/');
+    $url->scheme($spec->{schemes} && $spec->{schemes}[0] || undef);
+    $url->host('localhost') if $url->scheme and !$url->host;
+    return $url;
+  }
+
+  # Set
+  $url                = Mojo::URL->new($url)->to_abs($self->base_url);
+  $spec->{host}       = $url->host_port if $url->host_port;
+  $spec->{schemes}[0] = $url->scheme    if $url->scheme;
+  $spec->{basePath}   = $url->path->to_string || '/';
+  return $self;
+}
+
 sub coerce {
   my $self = shift;
   return $self->SUPER::coerce(@_) if @_;
@@ -202,6 +241,23 @@
   return $val->{value} = [split /,/,   $val->{value}];
 }
 
+sub _default_response_schema {
+  return {
+    type       => 'object',
+    required   => ['errors'],
+    properties => {
+      errors => {
+        type  => 'array',
+        items => {
+          type       => 'object',
+          required   => ['message'],
+          properties => {message => {type => 'string'}, path => {type => 
'string'}},
+        },
+      },
+    },
+  };
+}
+
 sub _definitions_path_for_ref {
   my ($self, $ref) = @_;
   my $path = Mojo::Path->new($ref->fqn =~ 
m!^.*#/(definitions|parameters|responses/.+)$!)->to_dir->parts;
@@ -230,6 +286,18 @@
   return $val;
 }
 
+sub _params_for_add_default_response {
+  my $self   = shift;
+  my $params = shift || {};
+
+  return {
+    description => $params->{description} || 'Default response.',
+    name        => $params->{name}        || 'DefaultResponse',
+    schema      => $params->{schema}      || _default_response_schema(),
+    status      => $params->{status}      || [400, 401, 404, 500, 501],
+  };
+}
+
 sub _prefix_error_path {
   return join '', "/$_[0]", $_[1] =~ /\w/ ? ($_[1]) : ();
 }
@@ -386,6 +454,58 @@
 
 =head1 METHODS
 
+=head2 add_default_response
+
+  $schema = $schema->add_default_response(\%params);
+
+Used to add a default response schema for operations that does not already have
+one. C<%params> can be:
+
+=over 2
+
+=item * description
+
+The human readable description added to the operation.
+
+Defaults: "Default response."
+
+=item * name
+
+The name used in the specification under "/components/schemas/".
+
+Defaults: "DefaultResponse"
+
+=item * schema
+
+The schema to add. The default schema below might change, but the basics will
+stay the same:
+
+  {
+    type: "object",
+    required: ["errors"],
+    properties: {
+      errors: {
+        type: "array",
+        items: {
+          type: "object",
+          required: ["message"],
+          properties: {
+            message: {type: "string"},
+            path: {type: "string"}
+          }
+        }
+      }
+    }
+  }
+
+=item * status
+
+A list of status codes to apply the default schema to.
+
+Default: C<[400, 401, 404, 500, 501]>.
+
+=back
+
 =head2 allow_invalid_ref
 
   $bool   = $schema->allow_invalid_ref;
@@ -399,6 +519,16 @@
 
 This method is highly EXPERIMENTAL, and it is not advices to use this method.
 
+=head2 base_url
+
+  $url = $schema->base_url;
+  $schema = $schema->base_url($url);
+
+Can get or set the default URL for this schema. C<$url> can be either a
+L<Mojo::URL> object or a plain string.
+
+This method will read or write "basePath", "host" and/or "schemas" in L</data>.
+
 =head2 coerce
 
   my $schema   = $schema->coerce({booleans => 1, numbers => 1, strings => 1});
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/JSON-Validator-4.16/lib/JSON/Validator/Schema/OpenAPIv3.pm 
new/JSON-Validator-4.17/lib/JSON/Validator/Schema/OpenAPIv3.pm
--- old/JSON-Validator-4.16/lib/JSON/Validator/Schema/OpenAPIv3.pm      
2021-03-23 23:57:14.000000000 +0100
+++ new/JSON-Validator-4.17/lib/JSON/Validator/Schema/OpenAPIv3.pm      
2021-04-28 04:01:44.000000000 +0200
@@ -14,7 +14,37 @@
 monkey_patch __PACKAGE__,
   $_ => JSON::Validator::Schema::OpenAPIv2->can($_)
   for qw(coerce routes validate_request validate_response),
-  qw(_coerce_arrays _coerce_default_value _find_all_nodes _prefix_error_path 
_validate_request_or_response);
+  qw(_coerce_arrays _coerce_default_value _find_all_nodes 
_params_for_add_default_response _prefix_error_path 
_validate_request_or_response);
+
+sub add_default_response {
+  my ($self, $params) = ($_[0], shift->_params_for_add_default_response(@_));
+
+  my $responses = $self->data->{components}{schemas} ||= {};
+  my $ref       = $responses->{$params->{name}}      ||= $params->{schema};
+  my %schema    = ('$ref' => "#/components/schemas/$params->{name}");
+  tie %schema, 'JSON::Validator::Ref', $ref, $schema{'$ref'}, $schema{'$ref'};
+
+  for my $route ($self->routes->each) {
+    my $op = $self->get([paths => @$route{qw(path method)}]);
+    $op->{responses}{$_}
+      ||= {description => $params->{description}, content => 
{'application/json' => {schema => \%schema}}}
+      for @{$params->{status}};
+  }
+
+  return $self;
+}
+
+sub base_url {
+  my ($self, $url) = @_;
+
+  # Get
+  return Mojo::URL->new($self->get('/servers/0/url') || '') unless $url;
+
+  # Set
+  $url = Mojo::URL->new($url)->to_abs($self->base_url);
+  $self->data->{servers}[0]{url} = $url->to_string;
+  return $self;
+}
 
 sub new {
   my $self = shift->SUPER::new(@_);
@@ -256,6 +286,11 @@
   return;
 }
 
+sub _validate_type_array {
+  my $self = shift;
+  return $_[2]->{nullable} && !defined $_[0] ? () : 
$self->SUPER::_validate_type_array(@_);
+}
+
 sub _validate_type_boolean {
   my $self = shift;
   return $_[2]->{nullable} && !defined $_[0] ? () : 
$self->SUPER::_validate_type_boolean(@_);
@@ -273,6 +308,7 @@
 
 sub _validate_type_object {
   my ($self, $data, $path, $schema) = @_;
+  return if $schema->{nullable} && !defined $data;
   return E $path, [object => type => data_type $data] if ref $data ne 'HASH';
   return shift->SUPER::_validate_type_object(@_) unless 
$self->{validate_request} or $self->{validate_response};
 
@@ -371,6 +407,22 @@
 
 =head1 METHODS
 
+=head2 add_default_response
+
+  $schema = $schema->add_default_response(\%params);
+
+See L<JSON::Validator::Schema::OpenAPIv2/add_default_response> for details.
+
+=head2 base_url
+
+  $url = $schema->base_url;
+  $schema = $schema->base_url($url);
+
+Can get or set the default URL for this schema. C<$url> can be either a
+L<Mojo::URL> object or a plain string.
+
+This method will read or write "/servers/0/url" in L</data>.
+
 =head2 coerce
 
   my $schema   = $schema->coerce({booleans => 1, numbers => 1, strings => 1});
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/JSON-Validator-4.16/lib/JSON/Validator.pm 
new/JSON-Validator-4.17/lib/JSON/Validator.pm
--- old/JSON-Validator-4.16/lib/JSON/Validator.pm       2021-03-24 
00:57:46.000000000 +0100
+++ new/JSON-Validator-4.17/lib/JSON/Validator.pm       2021-04-28 
04:30:56.000000000 +0200
@@ -16,7 +16,7 @@
 
 use constant RECURSION_LIMIT => $ENV{JSON_VALIDATOR_RECURSION_LIMIT} || 100;
 
-our $VERSION = '4.16';
+our $VERSION = '4.17';
 our @EXPORT_OK = qw(joi validate_json);
 
 our %SCHEMAS = (
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/JSON-Validator-4.16/t/draft2019-09-acceptance.t 
new/JSON-Validator-4.17/t/draft2019-09-acceptance.t
--- old/JSON-Validator-4.16/t/draft2019-09-acceptance.t 2021-01-24 
06:02:57.000000000 +0100
+++ new/JSON-Validator-4.17/t/draft2019-09-acceptance.t 2021-04-28 
04:17:57.000000000 +0200
@@ -1,14 +1,19 @@
 use lib '.';
 use t::Helper;
 
+$ENV{MOJO_LOG_LEVEL} //= 'fatal';
+
 plan skip_all => 'TEST_ACCEPTANCE=1' unless $ENV{TEST_ACCEPTANCE};
 delete $ENV{TEST_ACCEPTANCE} if $ENV{TEST_ACCEPTANCE} eq '1';
 
 my @todo_tests;
 push @todo_tests, ['',               'float and integers are equal up to 
64-bit representation limits'];
 push @todo_tests, ['defs.json',      'invalid definition'];
+push @todo_tests, ['defs.json',      'validate definition against metaschema'];
+push @todo_tests, ['id.json',        '$id inside an enum is not a real 
identifier'];
 push @todo_tests, ['ref.json',       'ref creates new scope when adjacent to 
keywords'];
 push @todo_tests, ['ref.json',       'remote ref, containing refs itself', 
'remote ref invalid'];
+push @todo_tests, ['anchor.json',    '$anchor inside an enum is not a real 
identifier'];
 push @todo_tests, ['anchor.json',    'Location-independent identifier with 
base URI change in subschema'];
 push @todo_tests, ['refRemote.json', 'remote ref'];
 push @todo_tests, ['recursiveRef.json'];
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/JSON-Validator-4.16/t/draft4-acceptance.t 
new/JSON-Validator-4.17/t/draft4-acceptance.t
--- old/JSON-Validator-4.16/t/draft4-acceptance.t       2021-01-24 
06:02:57.000000000 +0100
+++ new/JSON-Validator-4.17/t/draft4-acceptance.t       2021-04-28 
04:16:59.000000000 +0200
@@ -1,9 +1,14 @@
 use lib '.';
 use t::Helper;
 
+$ENV{MOJO_LOG_LEVEL} //= 'fatal';
+
 plan skip_all => 'TEST_ACCEPTANCE=1' unless $ENV{TEST_ACCEPTANCE};
 delete $ENV{TEST_ACCEPTANCE} if $ENV{TEST_ACCEPTANCE} eq '1';
 
-t::Helper->acceptance('JSON::Validator::Schema::Draft4');
+my @todo_tests;
+push @todo_tests, ['id.json', 'id inside an enum is not a real identifier'];
+
+t::Helper->acceptance('JSON::Validator::Schema::Draft4', todo_tests => 
\@todo_tests);
 
 done_testing;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/JSON-Validator-4.16/t/draft6-acceptance.t 
new/JSON-Validator-4.17/t/draft6-acceptance.t
--- old/JSON-Validator-4.16/t/draft6-acceptance.t       2021-01-24 
06:02:57.000000000 +0100
+++ new/JSON-Validator-4.17/t/draft6-acceptance.t       2021-04-28 
04:16:59.000000000 +0200
@@ -1,10 +1,13 @@
 use lib '.';
 use t::Helper;
 
+$ENV{MOJO_LOG_LEVEL} //= 'fatal';
+
 plan skip_all => 'TEST_ACCEPTANCE=1' unless $ENV{TEST_ACCEPTANCE};
 delete $ENV{TEST_ACCEPTANCE} if $ENV{TEST_ACCEPTANCE} eq '1';
 
 my @todo_tests;
+push @todo_tests, ['id.json',    'id inside an enum is not a real identifier'];
 push @todo_tests, ['const.json', 'float and integers are equal up to 64-bit 
representation limits'];
 
 t::Helper->acceptance('JSON::Validator::Schema::Draft6', todo_tests => 
\@todo_tests);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/JSON-Validator-4.16/t/draft7-acceptance.t 
new/JSON-Validator-4.17/t/draft7-acceptance.t
--- old/JSON-Validator-4.16/t/draft7-acceptance.t       2021-01-24 
06:02:57.000000000 +0100
+++ new/JSON-Validator-4.17/t/draft7-acceptance.t       2021-04-28 
04:17:00.000000000 +0200
@@ -1,10 +1,13 @@
 use lib '.';
 use t::Helper;
 
+$ENV{MOJO_LOG_LEVEL} //= 'fatal';
+
 plan skip_all => 'TEST_ACCEPTANCE=1' unless $ENV{TEST_ACCEPTANCE};
 delete $ENV{TEST_ACCEPTANCE} if $ENV{TEST_ACCEPTANCE} eq '1';
 
 my @todo_tests;
+push @todo_tests, ['id.json',    'id inside an enum is not a real identifier'];
 push @todo_tests, ['const.json', 'float and integers are equal up to 64-bit 
representation limits'];
 
 t::Helper->acceptance('JSON::Validator::Schema::Draft7', todo_tests => 
\@todo_tests);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/JSON-Validator-4.16/t/openapiv2-basic.t 
new/JSON-Validator-4.17/t/openapiv2-basic.t
--- old/JSON-Validator-4.16/t/openapiv2-basic.t 2021-02-23 06:57:46.000000000 
+0100
+++ new/JSON-Validator-4.17/t/openapiv2-basic.t 2021-04-28 03:40:51.000000000 
+0200
@@ -31,6 +31,24 @@
     ],
     'routes'
   );
+
+  is_deeply $schema->errors, [], 'errors';
+};
+
+subtest base_url => sub {
+  is $schema->base_url, 'http://petstore.swagger.io/v1', 'get';
+  is $schema->base_url('https://api.example.com:8080/api'), $schema, 'set url';
+  is_deeply $schema->get('/schemes'), ['https'], 'schemes changed';
+  is $schema->get('/host'),           'api.example.com:8080', 'host changed';
+  is $schema->get('/basePath'),       '/api',                 'basePath 
changed';
+
+  is $schema->base_url(Mojo::URL->new('//api2.example.com')), $schema, 'set 
without scheme';
+  is_deeply $schema->get('/schemes'), ['https'], 'schemes unchanged';
+  is $schema->get('/host'),           'api2.example.com', 'host changed';
+  is $schema->get('/basePath'),       '/',                'basePath changed';
+
+  is $schema->base_url(Mojo::URL->new('/v1')), $schema, 'set path';
+  is $schema->base_url->to_string, 'https://api2.example.com/v1', 'get';
 };
 
 subtest 'validate schema' => sub {
@@ -117,6 +135,21 @@
     'negotiated content type';
 };
 
+subtest add_default_response => sub {
+  $schema = JSON::Validator->new->schema($cwd->child(qw(spec 
v2-petstore.json)))->schema->resolve;
+  ok !$schema->get('/definitions/DefaultResponse'), 'default response missing';
+  ok !$schema->get([paths => '/petss', 'get', 'responses', '400']), 'default 
response missing for 400';
+  $schema->add_default_response;
+  ok $schema->get('/definitions/DefaultResponse'), 'default response added';
+
+  for my $status (400, 401, 404, 500, 501) {
+    ok $schema->get([paths => '/pets', 'get', 'responses', $status]), "default 
response for $status";
+  }
+
+  delete $schema->{errors};
+  is_deeply $schema->errors, [], 'errors';
+};
+
 done_testing;
 
 sub body {$body}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/JSON-Validator-4.16/t/openapiv3-basic.t 
new/JSON-Validator-4.17/t/openapiv3-basic.t
--- old/JSON-Validator-4.16/t/openapiv3-basic.t 2021-02-23 06:57:46.000000000 
+0100
+++ new/JSON-Validator-4.17/t/openapiv3-basic.t 2021-04-28 03:40:51.000000000 
+0200
@@ -29,6 +29,18 @@
   );
 };
 
+subtest base_url => sub {
+  is $schema->base_url, 'http://petstore.swagger.io/v1', 'get';
+  is $schema->base_url('https://api.example.com:8080/api'), $schema, 'set url';
+  is $schema->get('/servers/0/url'), 'https://api.example.com:8080/api', 
'servers changed';
+
+  is $schema->base_url(Mojo::URL->new('//api2.example.com')), $schema, 'set 
without scheme';
+  is $schema->get('/servers/0/url'), 'https://api2.example.com', 'servers 
changed';
+
+  is $schema->base_url(Mojo::URL->new('/v1')), $schema, 'set path';
+  is $schema->base_url->to_string, 'https://api2.example.com/v1', 'get';
+};
+
 subtest 'parameters_for_request' => sub {
   is $schema->parameters_for_request([GET => '/pets/nope']), undef, 'no such 
path';
   cmp_deeply $schema->parameters_for_request([GET => '/pets']), 
[superhashof({in => 'query', name => 'limit'})],
@@ -115,6 +127,21 @@
     'negotiated content type';
 };
 
+subtest add_default_response => sub {
+  $schema = JSON::Validator->new->schema($cwd->child(qw(spec 
v3-petstore.json)))->schema->resolve;
+  ok !$schema->get('/components/schemas/DefaultResponse'), 'default response 
missing';
+  ok !$schema->get([paths => '/petss', 'get', 'responses', '400']), 'default 
response missing for 400';
+  $schema->add_default_response;
+  ok $schema->get('/components/schemas/DefaultResponse'), 'default response 
added';
+
+  for my $status (400, 401, 404, 500, 501) {
+    ok $schema->get([paths => '/pets', 'get', 'responses', $status]), "default 
response for $status";
+  }
+
+  delete $schema->{errors};
+  is_deeply $schema->errors, [], 'errors';
+};
+
 done_testing;
 
 sub body {$body}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/JSON-Validator-4.16/t/openapiv3-nullable.t 
new/JSON-Validator-4.17/t/openapiv3-nullable.t
--- old/JSON-Validator-4.16/t/openapiv3-nullable.t      2021-03-23 
23:55:20.000000000 +0100
+++ new/JSON-Validator-4.17/t/openapiv3-nullable.t      2021-04-28 
04:01:44.000000000 +0200
@@ -15,6 +15,18 @@
   is "@errors", "", "$path - name is undef";
 }
 
+for my $extra ({}, undef) {
+  $body   = {exists => 1, value => {extra => $extra, id => 42, name => undef}};
+  @errors = $schema->validate_response([get => '/nullable-data'], {body => 
\&body});
+  is "@errors", "", sprintf 'extra %s', $extra ? 'object' : 'null';
+}
+
+for my $stuff ([], undef) {
+  $body   = {exists => 1, value => {stuff => $stuff, id => 42, name => undef}};
+  @errors = $schema->validate_response([get => '/nullable-data'], {body => 
\&body});
+  is "@errors", "", sprintf 'stuff %s', $stuff ? 'array' : 'null';
+}
+
 $schema = JSON::Validator->new->schema('data://main/issue-241.json')->schema;
 $body   = {exists => 1, value => {name => undef}};
 @errors = $schema->validate_response([get => '/test'], {body => \&body});
@@ -55,8 +67,10 @@
       "WithNullable": {
         "required": [ "id", "name" ],
         "properties": {
+          "extra": { "type": "object", "nullable": true },
           "id": { "type": "integer", "format": "int64" },
-          "name": { "type": "string", "nullable": true }
+          "name": { "type": "string", "nullable": true },
+          "stuff": { "type": "array", "nullable": true }
         }
       },
       "WithNullableRef": {

Reply via email to