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