line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package JSON::Schema::AsType::Draft6; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:YANICK'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Role processing draft6 JSON Schema |
4
|
|
|
|
|
|
|
$JSON::Schema::AsType::Draft6::VERSION = '0.4.1'; |
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
1232
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
57
|
|
7
|
2
|
|
|
2
|
|
5
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
51
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
6
|
use Moose::Role; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
18
|
|
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
7456
|
use Type::Utils; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
15
|
|
12
|
2
|
|
|
2
|
|
1821
|
use Scalar::Util qw/ looks_like_number /; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
109
|
|
13
|
2
|
|
|
2
|
|
8
|
use List::Util qw/ reduce pairmap pairs /; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
115
|
|
14
|
2
|
|
|
2
|
|
8
|
use List::MoreUtils qw/ any all none uniq zip /; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
12
|
|
15
|
2
|
|
|
2
|
|
1121
|
use Types::Standard qw/InstanceOf HashRef StrictNum Any Str ArrayRef Int slurpy Dict Optional slurpy /; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
14
|
|
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
2
|
|
2148
|
use JSON; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
12
|
|
18
|
|
|
|
|
|
|
|
19
|
2
|
|
|
2
|
|
221
|
use JSON::Schema::AsType; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
37
|
|
20
|
|
|
|
|
|
|
|
21
|
2
|
|
|
2
|
|
461
|
use JSON::Schema::AsType::Draft6::Types '-all'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
18
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
with 'JSON::Schema::AsType::Draft4'; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
override all_keywords => sub { |
26
|
|
|
|
|
|
|
my $self = shift; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# $ref trumps all |
29
|
|
|
|
|
|
|
return '$ref' if $self->schema->{'$ref'}; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
return uniq '$id', super(); |
32
|
|
|
|
|
|
|
}; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
override _build_type => sub { |
35
|
|
|
|
|
|
|
my $self = shift; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
return super() if ref $self->schema eq 'HASH'; |
38
|
|
|
|
|
|
|
|
39
|
2
|
|
|
2
|
|
18481
|
use JSON; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
11
|
|
40
|
|
|
|
|
|
|
return( ( $self->schema eq JSON::true) ? Any : ~Any ); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
}; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub _keyword_const { |
45
|
3
|
|
|
3
|
|
5
|
my $self = shift; |
46
|
|
|
|
|
|
|
|
47
|
3
|
|
|
|
|
17
|
$self->_keyword_enum([@_]); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub _keyword_contains { |
51
|
0
|
|
|
0
|
|
0
|
my( $self, $type ) = @_; |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
0
|
return Contains[ |
54
|
|
|
|
|
|
|
$self->sub_schema($type)->type |
55
|
|
|
|
|
|
|
]; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
}; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub _keyword_exclusiveMaximum { |
60
|
1
|
|
|
1
|
|
3
|
my( $self, $maximum ) = @_; |
61
|
|
|
|
|
|
|
|
62
|
1
|
|
|
|
|
6
|
ExclusiveMaximum[$maximum]; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub _keyword_exclusiveMinimum { |
66
|
0
|
|
|
0
|
|
0
|
my( $self, $maximum ) = @_; |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
0
|
ExclusiveMinimum[$maximum]; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub _keyword_propertyNames { |
72
|
3
|
|
|
3
|
|
5
|
my( $self, $schema ) = @_; |
73
|
|
|
|
|
|
|
|
74
|
3
|
|
|
|
|
12
|
PropertyNames[ $self->sub_schema($schema)->type ]; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub _keyword_items { |
78
|
1
|
|
|
1
|
|
2
|
my( $self, $items ) = @_; |
79
|
|
|
|
|
|
|
|
80
|
1
|
50
|
|
|
|
5
|
if ( Boolean->check($items) ) { |
81
|
0
|
0
|
|
|
|
0
|
return if $items; |
82
|
0
|
|
|
|
|
0
|
return Items[JSON::false]; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
1
|
50
|
|
|
|
8
|
if( ref $items eq 'HASH' ) { |
86
|
0
|
|
|
|
|
0
|
my $type = $self->sub_schema($items)->type; |
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
0
|
return Items[$type]; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# TODO forward declaration not workie |
92
|
1
|
|
|
|
|
3
|
my @types; |
93
|
1
|
|
|
|
|
3
|
for ( @$items ) { |
94
|
2
|
|
|
|
|
177
|
push @types, $self->sub_schema($_)->type; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
1
|
|
|
|
|
44
|
return Items[\@types]; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub _keyword_dependencies { |
101
|
0
|
|
|
0
|
|
0
|
my( $self, $dependencies ) = @_; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
return Dependencies[ |
104
|
|
|
|
|
|
|
pairmap { |
105
|
0
|
0
|
0
|
0
|
|
0
|
$a => ( ref $b eq 'HASH' or ref $b eq 'JSON::PP::Boolean' ) ? $self->sub_schema($b) |
106
|
0
|
|
|
|
|
0
|
: $b } %$dependencies |
107
|
|
|
|
|
|
|
]; |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
__PACKAGE__->meta->add_method( '_keyword_$id' => sub { |
112
|
1
|
|
|
1
|
|
3
|
my $self = shift; |
113
|
1
|
|
|
|
|
5
|
$self->_keyword_id(@_); |
114
|
|
|
|
|
|
|
} ); |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
1; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
__END__ |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=pod |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=encoding UTF-8 |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 NAME |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
JSON::Schema::AsType::Draft6 - Role processing draft6 JSON Schema |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 VERSION |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
version 0.4.1 |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 DESCRIPTION |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
This role is not intended to be used directly. It is used internally |
135
|
|
|
|
|
|
|
by L<JSON::Schema::AsType> objects. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Importing this module auto-populate the Draft4 schema in the |
138
|
|
|
|
|
|
|
L<JSON::Schema::AsType> schema cache. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 AUTHOR |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Yanick Champoux <yanick@babyl.dyndns.org> |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
This software is copyright (c) 2015 by Yanick Champoux. |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
149
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=cut |