zigorou / perl-JSV

JSON Schema implementation for Perl
Other
25 stars 17 forks source link

Lost base_uri with recursive reference #7

Closed zigorou closed 11 years ago

zigorou commented 11 years ago
use strict;
use warnings;

use JSV::Validator;
use Test::More;

my $s1 = +{
    id => "http://example.com/s1",
    definitions => {
        POSITIVE_INT => { type => "integer", minimum => 1 },
        SMALL_INT => { type => "integer", maximum => 65535 },
        SMALL_INT_AND_POSITIVE_INT => {
            "allOf" => [
                +{ '$ref' => "#/definitions/POSITIVE_INT" },
                +{ '$ref' => "#/definitions/SMALL_INT" },
            ]
        }
    }
};

my $s2 = +{
    oneOf => [
        +{ enum => [qw/none/] },
        +{ '$ref' => "http://example.com/s1#/definitions/SMALL_INT_AND_POSITIVE_INT" }
    ]
};

my $v = JSV::Validator->new( environment => "draft4" );
$v->reference->register_schema("http://example.com/s1" => $s1);
my $rv = $v->validate($s2, "none");
note $rv;
note explain $s2;

ok 1;

done_testing;