Hello community,
here is the log from the commit of package perl-JSON-Validator for
openSUSE:Factory checked in at 2020-02-14 16:41:11
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/perl-JSON-Validator (Old)
and /work/SRC/openSUSE:Factory/.perl-JSON-Validator.new.26092 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-JSON-Validator"
Fri Feb 14 16:41:11 2020 rev:14 rq:774343 version:3.21
Changes:
--------
--- /work/SRC/openSUSE:Factory/perl-JSON-Validator/perl-JSON-Validator.changes
2020-02-13 10:11:53.808353240 +0100
+++
/work/SRC/openSUSE:Factory/.perl-JSON-Validator.new.26092/perl-JSON-Validator.changes
2020-02-14 16:41:26.659721830 +0100
@@ -1,0 +2,9 @@
+Fri Feb 14 03:07:59 UTC 2020 - <[email protected]>
+
+- updated to 3.21
+ see /usr/share/doc/packages/perl-JSON-Validator/Changes
+
+ 3.21 2020-02-14T10:14:14+0900
+ - Fix data_section() without a class #193
+
+-------------------------------------------------------------------
Old:
----
JSON-Validator-3.20.tar.gz
New:
----
JSON-Validator-3.21.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ perl-JSON-Validator.spec ++++++
--- /var/tmp/diff_new_pack.8s9Z16/_old 2020-02-14 16:41:27.483722290 +0100
+++ /var/tmp/diff_new_pack.8s9Z16/_new 2020-02-14 16:41:27.487722292 +0100
@@ -17,7 +17,7 @@
Name: perl-JSON-Validator
-Version: 3.20
+Version: 3.21
Release: 0
%define cpan_name JSON-Validator
Summary: Validate data against a JSON schema
++++++ JSON-Validator-3.20.tar.gz -> JSON-Validator-3.21.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/JSON-Validator-3.20/Changes
new/JSON-Validator-3.21/Changes
--- old/JSON-Validator-3.20/Changes 2020-02-12 01:47:21.000000000 +0100
+++ new/JSON-Validator-3.21/Changes 2020-02-14 02:14:14.000000000 +0100
@@ -1,5 +1,8 @@
Revision history for perl distribution JSON-Validator
+3.21 2020-02-14T10:14:14+0900
+ - Fix data_section() without a class #193
+
3.20 2020-02-12T09:47:21+0900
- Fix validating draft6 "false" and "true" schemas #190
Contributor: Karen Etheridge
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/JSON-Validator-3.20/META.json
new/JSON-Validator-3.21/META.json
--- old/JSON-Validator-3.20/META.json 2020-02-12 01:47:22.000000000 +0100
+++ new/JSON-Validator-3.21/META.json 2020-02-14 02:14:15.000000000 +0100
@@ -61,6 +61,6 @@
},
"x_IRC" : "irc://irc.freenode.net/#mojo"
},
- "version" : "3.20",
+ "version" : "3.21",
"x_serialization_backend" : "JSON::PP version 4.02"
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/JSON-Validator-3.20/META.yml
new/JSON-Validator-3.21/META.yml
--- old/JSON-Validator-3.20/META.yml 2020-02-12 01:47:22.000000000 +0100
+++ new/JSON-Validator-3.21/META.yml 2020-02-14 02:14:15.000000000 +0100
@@ -30,5 +30,5 @@
homepage: https://mojolicious.org
license: http://www.opensource.org/licenses/artistic-license-2.0
repository: https://github.com/mojolicious/json-validator.git
-version: '3.20'
+version: '3.21'
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/JSON-Validator-3.20/lib/JSON/Validator/Util.pm
new/JSON-Validator-3.21/lib/JSON/Validator/Util.pm
--- old/JSON-Validator-3.20/lib/JSON/Validator/Util.pm 2020-02-12
01:38:10.000000000 +0100
+++ new/JSON-Validator-3.21/lib/JSON/Validator/Util.pm 2020-02-14
02:12:56.000000000 +0100
@@ -1,10 +1,12 @@
package JSON::Validator::Util;
use Mojo::Base -strict;
+use Carp ();
use Data::Dumper ();
use Exporter 'import';
use JSON::Validator::Error;
use Mojo::Collection;
+use Mojo::JSON;
use Mojo::Loader;
use Mojo::Util;
use Scalar::Util 'blessed';
@@ -20,26 +22,32 @@
sub data_section {
my ($class, $file, $params) = @_;
- state $class_skip_re
- = qr{(^JSON::Validator$|^Mojo::Base$|^Mojolicious$|\w+::_Dynamic)};
+ state $skip_re
+ = qr{(^JSON::Validator|^Mojo::Base$|^Mojolicious$|\w+::_Dynamic)};
- unless ($class) {
- my $i = 1;
+ my @classes = $class ? ([$class]) : ();
+ unless (@classes) {
+ my $i = 0;
while ($class = caller($i++)) {
- last unless $class =~ $class_skip_re;
+ push @classes, [$class] unless $class =~ $skip_re;
}
}
- my @classes = do { no strict 'refs'; ($class, @{"$class\::ISA"}) };
- my $text;
- for my $class (@classes) {
- next if $class =~ $class_skip_re;
- last if $text = Mojo::Loader::data_section($class, $file);
+ for my $group (@classes) {
+ push @$group,
+ grep { !/$skip_re/ } do { no strict 'refs'; @{"$group->[0]\::ISA"} };
+ for my $class (@$group) {
+ next unless my $text = Mojo::Loader::data_section($class, $file);
+ return Mojo::Util::encode($params->{encoding}, $text)
+ if $params->{encoding};
+ return $text;
+ }
}
- $text = Mojo::Util::encode($params->{encoding}, $text)
- if $text and $params->{encoding};
- $text;
+ return undef unless $params->{confess};
+
+ my $err = Mojo::JSON::encode_json([map { @$_ == 1 ? $_->[0] : $_ }
@classes]);
+ Carp::confess(qq(Could not find "$file" in __DATA__ section of $err.));
}
sub data_type {
@@ -231,7 +239,7 @@
$bool = is_type $any, $class;
$bool = is_type $any, $type; # $type = "ARRAY", "BOOL", "HASH", "NUM" ...
-Checks if C<$any> is a, or inherit from C<$class> or C<$type>. Two special
+Checks if C<$any> is a, or inherits from, C<$class> or C<$type>. Two special
types can be checked:
=over 2
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/JSON-Validator-3.20/lib/JSON/Validator.pm
new/JSON-Validator-3.21/lib/JSON/Validator.pm
--- old/JSON-Validator-3.20/lib/JSON/Validator.pm 2020-02-12
01:47:21.000000000 +0100
+++ new/JSON-Validator-3.21/lib/JSON/Validator.pm 2020-02-14
02:14:14.000000000 +0100
@@ -21,9 +21,9 @@
use constant DEBUG => $ENV{JSON_VALIDATOR_DEBUG} || 0;
use constant RECURSION_LIMIT => $ENV{JSON_VALIDATOR_RECURSION_LIMIT} || 100;
use constant SPECIFICATION_URL => 'http://json-schema.org/draft-04/schema#';
+use constant YAML_SUPPORT => eval 'use YAML::XS 0.67;1';
-our $VERSION = '3.20';
-our $YAML_LOADER = eval q[use YAML::XS 0.67; YAML::XS->can('Load')]; #
internal
+our $VERSION = '3.21';
our @EXPORT_OK = qw(joi validate_json);
my $BUNDLED_CACHE_DIR = path(path(__FILE__)->dirname, qw(Validator cache));
@@ -112,7 +112,7 @@
}
}
elsif (ref $from eq 'HASH') {
- while (my ($key, $value) = each %$from) {
+ for my $key (keys %$from) {
$to->{$key} //= $cloner->($from->{$key});
}
}
@@ -263,9 +263,8 @@
if ($url =~ m!^data://([^/]*)/(.*)!) {
my ($class, $file) = ($1, $2);
- my $text = data_section $class, $file, {encoding => 'UTF-8'};
- return $self->_load_schema_from_text(\$text), "$url" if $text;
- confess "$file could not be found in __DATA__ section of $class.";
+ my $text = data_section $class, $file, {confess => 1, encoding => 'UTF-8'};
+ return $self->_load_schema_from_text(\$text), "$url";
}
if ($url =~ m!^\s*[\[\{]!) {
@@ -300,22 +299,12 @@
return Mojo::JSON::decode_json($$text) if $$text =~ /^\s*\{/s;
# YAML
- $visit = sub {
- my $v = shift;
- $visit->($_) for grep { ref $_ eq 'HASH' } values %$v;
- unless ($v->{type} and $v->{type} eq 'boolean' and exists $v->{default}) {
- return $v;
- }
- %$v = (%$v, default => $v->{default} ? true : false);
- return $v;
- };
-
die "[JSON::Validator] YAML::XS 0.67 is missing or could not be loaded."
- unless $YAML_LOADER;
+ unless YAML_SUPPORT;
no warnings 'once';
local $YAML::XS::Boolean = 'JSON::PP';
- return $visit->($YAML_LOADER->($$text));
+ return YAML::XS::Load($$text);
}
sub _load_schema_from_url {
@@ -846,13 +835,12 @@
sub _validate_type_object {
my ($self, $data, $path, $schema) = @_;
- my %required = map { ($_ => 1) } @{$schema->{required} || []};
- my ($additional, @errors, %rules);
if (ref $data ne 'HASH') {
return E $path, [object => type => data_type $data];
}
+ my @errors;
my @dkeys = sort keys %$data;
if (defined $schema->{maxProperties} and $schema->{maxProperties} < @dkeys) {
push @errors, E $path,
@@ -875,10 +863,11 @@
: $self->_validate($data, $path, $schema->{then} // {});
}
- my $coerce = $self->{coerce}{defaults};
- while (my ($k, $r) = each %{$schema->{properties}}) {
+ my %rules;
+ for my $k (keys %{$schema->{properties}}) {
+ my $r = $schema->{properties}{$k};
push @{$rules{$k}}, $r;
- if ( $coerce
+ if ( $self->{coerce}{defaults}
and ref $r eq 'HASH'
and exists $r->{default}
and !exists $data->{$k})
@@ -887,11 +876,12 @@
}
}
- while (my ($p, $r) = each %{$schema->{patternProperties} || {}}) {
+ for my $p (keys %{$schema->{patternProperties} || {}}) {
+ my $r = $schema->{patternProperties}{$p};
push @{$rules{$_}}, $r for sort grep { $_ =~ /$p/ } @dkeys;
}
- $additional
+ my $additional
= exists $schema->{additionalProperties}
? $schema->{additionalProperties}
: {};
@@ -904,7 +894,7 @@
return E $path, [object => additionalProperties => join '/', @k];
}
- for my $k (sort keys %required) {
+ for my $k (sort uniq @{$schema->{required} || []}) {
next if exists $data->{$k};
push @errors, E json_pointer($path, $k), [object => 'required'];
delete $rules{$k};
@@ -1039,7 +1029,7 @@
=item * L<http://json-schema.org/documentation.html>
-=item * L<http://spacetelescope.github.io/understanding-json-schema/index.html>
+=item * L<https://json-schema.org/understanding-json-schema/index.html>
=item * L<https://github.com/json-schema/json-schema/>
@@ -1196,7 +1186,7 @@
Used to create a new schema, where there are no "$ref" pointing to external
resources. This means that all the "$ref" that are found, will be moved into
-the "definitions" key, in the returning C<$schema>.
+the "definitions" key, in the returned C<$schema>.
=head2 coerce
@@ -1212,7 +1202,8 @@
=item * booleans
-Will convert what looks can be interpreted as a boolean to a
+Will convert what looks can be interpreted as a boolean (that is, an actual
+numeric C<1> or C<0>, and the strings "true" and "false") to a
L<JSON::PP::Boolean> object. Note that "foo" is not considered a true value and
will fail the validation.
@@ -1235,10 +1226,6 @@
=back
-Loading a YAML document will enable "booleans" automatically. This feature is
-experimental, but was added since YAML has no real concept of booleans, such
-as L<Mojo::JSON> or other JSON parsers.
-
=head2 get
my $sub_schema = $jv->get("/x/y");
@@ -1248,7 +1235,7 @@
same time resolve C<$ref> if found. Example:
$jv->schema({x => {'$ref' => '#/y'}, y => {'type' => 'string'}});
- $jv->schema->get('/x') == undef
+ $jv->schema->get('/x') == {'$ref' => '#/y'}
$jv->schema->get('/x')->{'$ref'} == '#/y'
$jv->get('/x') == {type => 'string'}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/JSON-Validator-3.20/t/booleans.t
new/JSON-Validator-3.21/t/booleans.t
--- old/JSON-Validator-3.20/t/booleans.t 2020-02-08 01:27:55.000000000
+0100
+++ new/JSON-Validator-3.21/t/booleans.t 2020-02-14 02:12:56.000000000
+0100
@@ -22,7 +22,7 @@
validate_ok {v => ''}, $schema, E('/v', 'Expected boolean - got string.');
SKIP: {
- skip 'YAML::XS is not installed', 1 unless $JSON::Validator::YAML_LOADER;
+ skip 'YAML::XS is not installed', 1 unless JSON::Validator->YAML_SUPPORT;
my $data = jv->_load_schema_from_text(\"---\nv: true\n");
isa_ok($data->{v}, 'JSON::PP::Boolean');
validate_ok $data, $schema;
@@ -34,8 +34,7 @@
{type => 'object', properties => {type => {type => 'string'}}};
}
-SKIP: {
- skip 'Cpanel::JSON::XS not installed', 2 unless
$JSON::Validator::YAML_LOADER;
+{
validate_ok {disabled => Mojo::JSON->true},
{properties => {disabled => {type => 'boolean'}}};
validate_ok {disabled => Mojo::JSON->false},
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/JSON-Validator-3.20/t/load-data.t
new/JSON-Validator-3.21/t/load-data.t
--- old/JSON-Validator-3.20/t/load-data.t 2020-02-08 01:27:55.000000000
+0100
+++ new/JSON-Validator-3.21/t/load-data.t 2020-02-14 01:23:39.000000000
+0100
@@ -23,6 +23,13 @@
ok !Some::Module->validate_age0({age => 1}), 'validate_age0';
ok !Some::Module->validate_age1({age => 1}), 'validate_age1';
+eval { Mojolicious::Plugin::TestX->validate('data:///spec.json', {}) };
+ok !$@, 'found spec.json in main' or diag $@;
+
+package Mojolicious::Plugin::TestX;
+sub validate { $jv->schema($_[1])->validate($_[2]) }
+
+package main;
done_testing;
__DATA__
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/JSON-Validator-3.20/t/load-yaml.t
new/JSON-Validator-3.21/t/load-yaml.t
--- old/JSON-Validator-3.20/t/load-yaml.t 2020-02-08 01:27:55.000000000
+0100
+++ new/JSON-Validator-3.21/t/load-yaml.t 2020-02-14 02:12:56.000000000
+0100
@@ -2,7 +2,7 @@
use JSON::Validator;
use Test::More;
-plan skip_all => 'YAML::XS required' unless $JSON::Validator::YAML_LOADER;
+plan skip_all => 'YAML::XS required' unless JSON::Validator->YAML_SUPPORT;
my $jv = JSON::Validator->new;
my @errors = $jv->schema('data://Some::Module/s_pec-/-ficaTion')
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/JSON-Validator-3.20/t/more-bundle.t
new/JSON-Validator-3.21/t/more-bundle.t
--- old/JSON-Validator-3.20/t/more-bundle.t 2020-02-10 05:19:54.000000000
+0100
+++ new/JSON-Validator-3.21/t/more-bundle.t 2020-02-14 02:12:56.000000000
+0100
@@ -4,7 +4,7 @@
use Test::More;
plan skip_all => 'YAML::XS is not installed'
- unless $JSON::Validator::YAML_LOADER;
+ unless JSON::Validator->YAML_SUPPORT;
# these are triples:
# - schema name to extract from schema file(s) with bundle()