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.2'; |
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
1250
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
57
|
|
7
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
56
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
9
|
use Moose::Role; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
18
|
|
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
10165
|
use Type::Utils; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
17
|
|
12
|
2
|
|
|
2
|
|
3009
|
use Scalar::Util qw/ looks_like_number /; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
117
|
|
13
|
2
|
|
|
2
|
|
11
|
use List::Util qw/ reduce pairmap pairs /; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
118
|
|
14
|
2
|
|
|
2
|
|
11
|
use List::MoreUtils qw/ any all none uniq zip /; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
14
|
|
15
|
2
|
|
|
2
|
|
1700
|
use Types::Standard qw/InstanceOf HashRef StrictNum Any Str ArrayRef Int slurpy Dict Optional slurpy /; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
15
|
|
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
2
|
|
3280
|
use JSON; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
13
|
|
18
|
|
|
|
|
|
|
|
19
|
2
|
|
|
2
|
|
244
|
use JSON::Schema::AsType; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
39
|
|
20
|
|
|
|
|
|
|
|
21
|
2
|
|
|
2
|
|
388
|
use JSON::Schema::AsType::Draft6::Types '-all'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
16
|
|
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
|
|
32347
|
use JSON; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
11
|
|
40
|
|
|
|
|
|
|
return( ( $self->schema eq JSON::true) ? Any : ~Any ); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
}; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub _keyword_const { |
45
|
4
|
|
|
4
|
|
9
|
my $self = shift; |
46
|
|
|
|
|
|
|
|
47
|
4
|
|
|
|
|
21
|
$self->_keyword_enum([@_]); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub _keyword_contains { |
51
|
4
|
|
|
4
|
|
17
|
my( $self, $type ) = @_; |
52
|
|
|
|
|
|
|
|
53
|
4
|
|
|
|
|
23
|
return Contains[ |
54
|
|
|
|
|
|
|
$self->sub_schema($type)->type |
55
|
|
|
|
|
|
|
]; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
}; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub _keyword_exclusiveMaximum { |
60
|
1
|
|
|
1
|
|
4
|
my( $self, $maximum ) = @_; |
61
|
|
|
|
|
|
|
|
62
|
1
|
|
|
|
|
8
|
ExclusiveMaximum[$maximum]; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub _keyword_exclusiveMinimum { |
66
|
1
|
|
|
1
|
|
4
|
my( $self, $maximum ) = @_; |
67
|
|
|
|
|
|
|
|
68
|
1
|
|
|
|
|
8
|
ExclusiveMinimum[$maximum]; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub _keyword_propertyNames { |
72
|
3
|
|
|
3
|
|
8
|
my( $self, $schema ) = @_; |
73
|
|
|
|
|
|
|
|
74
|
3
|
|
|
|
|
10
|
PropertyNames[ $self->sub_schema($schema)->type ]; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub _keyword_items { |
78
|
39
|
|
|
39
|
|
143
|
my( $self, $items ) = @_; |
79
|
|
|
|
|
|
|
|
80
|
39
|
100
|
|
|
|
185
|
if ( Boolean->check($items) ) { |
81
|
2
|
100
|
|
|
|
18
|
return if $items; |
82
|
1
|
|
|
|
|
13
|
return Items[JSON::false]; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
37
|
100
|
|
|
|
298
|
if( ref $items eq 'HASH' ) { |
86
|
31
|
|
|
|
|
163
|
my $type = $self->sub_schema($items)->type; |
87
|
|
|
|
|
|
|
|
88
|
31
|
|
|
|
|
1603
|
return Items[$type]; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# TODO forward declaration not workie |
92
|
6
|
|
|
|
|
12
|
my @types; |
93
|
6
|
|
|
|
|
16
|
for ( @$items ) { |
94
|
11
|
|
|
|
|
726
|
push @types, $self->sub_schema($_)->type; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
6
|
|
|
|
|
856
|
return Items[\@types]; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub _keyword_dependencies { |
101
|
5
|
|
|
5
|
|
18
|
my( $self, $dependencies ) = @_; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
return Dependencies[ |
104
|
|
|
|
|
|
|
pairmap { |
105
|
6
|
100
|
100
|
6
|
|
148
|
$a => ( ref $b eq 'HASH' or ref $b eq 'JSON::PP::Boolean' ) ? $self->sub_schema($b) |
106
|
5
|
|
|
|
|
80
|
: $b } %$dependencies |
107
|
|
|
|
|
|
|
]; |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
__PACKAGE__->meta->add_method( '_keyword_$id' => sub { |
112
|
190
|
|
|
190
|
|
395
|
my $self = shift; |
113
|
190
|
|
|
|
|
796
|
$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.2 |
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 |