| 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.4'; |
|
5
|
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
139081
|
use strict; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
114
|
|
|
7
|
3
|
|
|
3
|
|
13
|
use warnings; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
193
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
366
|
use Moose::Role; |
|
|
3
|
|
|
|
|
458311
|
|
|
|
3
|
|
|
|
|
26
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
3
|
|
|
3
|
|
17485
|
use Type::Utils; |
|
|
3
|
|
|
|
|
47804
|
|
|
|
3
|
|
|
|
|
42
|
|
|
12
|
3
|
|
|
3
|
|
5510
|
use Scalar::Util qw/ looks_like_number /; |
|
|
3
|
|
|
|
|
9
|
|
|
|
3
|
|
|
|
|
226
|
|
|
13
|
3
|
|
|
3
|
|
20
|
use List::Util qw/ reduce pairmap pairs /; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
210
|
|
|
14
|
3
|
|
|
3
|
|
534
|
use List::MoreUtils qw/ any all none uniq zip /; |
|
|
3
|
|
|
|
|
7856
|
|
|
|
3
|
|
|
|
|
28
|
|
|
15
|
3
|
|
|
3
|
|
5320
|
use Types::Standard qw/InstanceOf HashRef StrictNum Any Str ArrayRef Int slurpy Dict Optional slurpy /; |
|
|
3
|
|
|
|
|
73179
|
|
|
|
3
|
|
|
|
|
33
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
3
|
|
|
3
|
|
13342
|
use JSON; |
|
|
3
|
|
|
|
|
8725
|
|
|
|
3
|
|
|
|
|
21
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
3
|
|
|
3
|
|
878
|
use JSON::Schema::AsType; |
|
|
3
|
|
|
|
|
9
|
|
|
|
3
|
|
|
|
|
107
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
3
|
|
|
3
|
|
1041
|
use JSON::Schema::AsType::Draft6::Types '-all'; |
|
|
3
|
|
|
|
|
12
|
|
|
|
3
|
|
|
|
|
37
|
|
|
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
|
3
|
|
|
3
|
|
36351
|
use JSON; |
|
|
3
|
|
|
|
|
9
|
|
|
|
3
|
|
|
|
|
22
|
|
|
40
|
|
|
|
|
|
|
return( ( $self->schema eq JSON::true) ? Any : ~Any ); |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
}; |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub _keyword_const { |
|
45
|
4
|
|
|
4
|
|
15
|
my $self = shift; |
|
46
|
|
|
|
|
|
|
|
|
47
|
4
|
|
|
|
|
35
|
$self->_keyword_enum([@_]); |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub _keyword_contains { |
|
51
|
4
|
|
|
4
|
|
15
|
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
|
|
3
|
my( $self, $maximum ) = @_; |
|
61
|
|
|
|
|
|
|
|
|
62
|
1
|
|
|
|
|
6
|
ExclusiveMaximum[$maximum]; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub _keyword_exclusiveMinimum { |
|
66
|
4
|
|
|
4
|
|
18
|
my( $self, $maximum ) = @_; |
|
67
|
|
|
|
|
|
|
|
|
68
|
4
|
|
|
|
|
35
|
ExclusiveMinimum[$maximum]; |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub _keyword_propertyNames { |
|
72
|
6
|
|
|
6
|
|
19
|
my( $self, $schema ) = @_; |
|
73
|
|
|
|
|
|
|
|
|
74
|
6
|
|
|
|
|
44
|
PropertyNames[ $self->sub_schema($schema)->type ]; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub _keyword_items { |
|
78
|
51
|
|
|
51
|
|
179
|
my( $self, $items ) = @_; |
|
79
|
|
|
|
|
|
|
|
|
80
|
51
|
100
|
|
|
|
320
|
if ( Boolean->check($items) ) { |
|
81
|
2
|
100
|
|
|
|
44
|
return if $items; |
|
82
|
1
|
|
|
|
|
18
|
return Items[JSON::false]; |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
49
|
100
|
|
|
|
411
|
if( ref $items eq 'HASH' ) { |
|
86
|
43
|
|
|
|
|
215
|
my $type = $self->sub_schema($items)->type; |
|
87
|
|
|
|
|
|
|
|
|
88
|
43
|
|
|
|
|
2745
|
return Items[$type]; |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# TODO forward declaration not workie |
|
92
|
6
|
|
|
|
|
16
|
my @types; |
|
93
|
6
|
|
|
|
|
20
|
for ( @$items ) { |
|
94
|
11
|
|
|
|
|
1307
|
push @types, $self->sub_schema($_)->type; |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
6
|
|
|
|
|
1213
|
return Items[\@types]; |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub _keyword_dependencies { |
|
101
|
5
|
|
|
5
|
|
16
|
my( $self, $dependencies ) = @_; |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
return Dependencies[ |
|
104
|
|
|
|
|
|
|
pairmap { |
|
105
|
6
|
100
|
100
|
6
|
|
135
|
$a => ( ref $b eq 'HASH' or ref $b eq 'JSON::PP::Boolean' ) ? $self->sub_schema($b) |
|
106
|
5
|
|
|
|
|
75
|
: $b } %$dependencies |
|
107
|
|
|
|
|
|
|
]; |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
__PACKAGE__->meta->add_method( '_keyword_$id' => sub { |
|
112
|
192
|
|
|
192
|
|
486
|
my $self = shift; |
|
113
|
192
|
|
|
|
|
1072
|
$self->_keyword_id(@_); |
|
114
|
|
|
|
|
|
|
} ); |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
JSON::Schema::AsType->new( |
|
118
|
|
|
|
|
|
|
specification => 'draft6', |
|
119
|
|
|
|
|
|
|
uri => 'https://json-schema.org/draft-06/schema', |
|
120
|
|
|
|
|
|
|
schema => from_json <<'END_JSON' )->type; |
|
121
|
|
|
|
|
|
|
{ |
|
122
|
|
|
|
|
|
|
"$schema": "https://json-schema.org/draft-06/schema#", |
|
123
|
|
|
|
|
|
|
"$id": "https://json-schema.org/draft-06/schema#", |
|
124
|
|
|
|
|
|
|
"title": "Core schema meta-schema", |
|
125
|
|
|
|
|
|
|
"definitions": { |
|
126
|
|
|
|
|
|
|
"schemaArray": { |
|
127
|
|
|
|
|
|
|
"type": "array", |
|
128
|
|
|
|
|
|
|
"minItems": 1, |
|
129
|
|
|
|
|
|
|
"items": { "$ref": "#" } |
|
130
|
|
|
|
|
|
|
}, |
|
131
|
|
|
|
|
|
|
"nonNegativeInteger": { |
|
132
|
|
|
|
|
|
|
"type": "integer", |
|
133
|
|
|
|
|
|
|
"minimum": 0 |
|
134
|
|
|
|
|
|
|
}, |
|
135
|
|
|
|
|
|
|
"nonNegativeIntegerDefault0": { |
|
136
|
|
|
|
|
|
|
"allOf": [ |
|
137
|
|
|
|
|
|
|
{ "$ref": "#/definitions/nonNegativeInteger" }, |
|
138
|
|
|
|
|
|
|
{ "default": 0 } |
|
139
|
|
|
|
|
|
|
] |
|
140
|
|
|
|
|
|
|
}, |
|
141
|
|
|
|
|
|
|
"simpleTypes": { |
|
142
|
|
|
|
|
|
|
"enum": [ |
|
143
|
|
|
|
|
|
|
"array", |
|
144
|
|
|
|
|
|
|
"boolean", |
|
145
|
|
|
|
|
|
|
"integer", |
|
146
|
|
|
|
|
|
|
"null", |
|
147
|
|
|
|
|
|
|
"number", |
|
148
|
|
|
|
|
|
|
"object", |
|
149
|
|
|
|
|
|
|
"string" |
|
150
|
|
|
|
|
|
|
] |
|
151
|
|
|
|
|
|
|
}, |
|
152
|
|
|
|
|
|
|
"stringArray": { |
|
153
|
|
|
|
|
|
|
"type": "array", |
|
154
|
|
|
|
|
|
|
"items": { "type": "string" }, |
|
155
|
|
|
|
|
|
|
"uniqueItems": true, |
|
156
|
|
|
|
|
|
|
"default": [] |
|
157
|
|
|
|
|
|
|
} |
|
158
|
|
|
|
|
|
|
}, |
|
159
|
|
|
|
|
|
|
"type": ["object", "boolean"], |
|
160
|
|
|
|
|
|
|
"properties": { |
|
161
|
|
|
|
|
|
|
"$id": { |
|
162
|
|
|
|
|
|
|
"type": "string", |
|
163
|
|
|
|
|
|
|
"format": "uri-reference" |
|
164
|
|
|
|
|
|
|
}, |
|
165
|
|
|
|
|
|
|
"$schema": { |
|
166
|
|
|
|
|
|
|
"type": "string", |
|
167
|
|
|
|
|
|
|
"format": "uri" |
|
168
|
|
|
|
|
|
|
}, |
|
169
|
|
|
|
|
|
|
"$ref": { |
|
170
|
|
|
|
|
|
|
"type": "string", |
|
171
|
|
|
|
|
|
|
"format": "uri-reference" |
|
172
|
|
|
|
|
|
|
}, |
|
173
|
|
|
|
|
|
|
"title": { |
|
174
|
|
|
|
|
|
|
"type": "string" |
|
175
|
|
|
|
|
|
|
}, |
|
176
|
|
|
|
|
|
|
"description": { |
|
177
|
|
|
|
|
|
|
"type": "string" |
|
178
|
|
|
|
|
|
|
}, |
|
179
|
|
|
|
|
|
|
"default": {}, |
|
180
|
|
|
|
|
|
|
"examples": { |
|
181
|
|
|
|
|
|
|
"type": "array", |
|
182
|
|
|
|
|
|
|
"items": {} |
|
183
|
|
|
|
|
|
|
}, |
|
184
|
|
|
|
|
|
|
"multipleOf": { |
|
185
|
|
|
|
|
|
|
"type": "number", |
|
186
|
|
|
|
|
|
|
"exclusiveMinimum": 0 |
|
187
|
|
|
|
|
|
|
}, |
|
188
|
|
|
|
|
|
|
"maximum": { |
|
189
|
|
|
|
|
|
|
"type": "number" |
|
190
|
|
|
|
|
|
|
}, |
|
191
|
|
|
|
|
|
|
"exclusiveMaximum": { |
|
192
|
|
|
|
|
|
|
"type": "number" |
|
193
|
|
|
|
|
|
|
}, |
|
194
|
|
|
|
|
|
|
"minimum": { |
|
195
|
|
|
|
|
|
|
"type": "number" |
|
196
|
|
|
|
|
|
|
}, |
|
197
|
|
|
|
|
|
|
"exclusiveMinimum": { |
|
198
|
|
|
|
|
|
|
"type": "number" |
|
199
|
|
|
|
|
|
|
}, |
|
200
|
|
|
|
|
|
|
"maxLength": { "$ref": "#/definitions/nonNegativeInteger" }, |
|
201
|
|
|
|
|
|
|
"minLength": { "$ref": "#/definitions/nonNegativeIntegerDefault0" }, |
|
202
|
|
|
|
|
|
|
"pattern": { |
|
203
|
|
|
|
|
|
|
"type": "string", |
|
204
|
|
|
|
|
|
|
"format": "regex" |
|
205
|
|
|
|
|
|
|
}, |
|
206
|
|
|
|
|
|
|
"additionalItems": { "$ref": "#" }, |
|
207
|
|
|
|
|
|
|
"items": { |
|
208
|
|
|
|
|
|
|
"anyOf": [ |
|
209
|
|
|
|
|
|
|
{ "$ref": "#" }, |
|
210
|
|
|
|
|
|
|
{ "$ref": "#/definitions/schemaArray" } |
|
211
|
|
|
|
|
|
|
], |
|
212
|
|
|
|
|
|
|
"default": {} |
|
213
|
|
|
|
|
|
|
}, |
|
214
|
|
|
|
|
|
|
"maxItems": { "$ref": "#/definitions/nonNegativeInteger" }, |
|
215
|
|
|
|
|
|
|
"minItems": { "$ref": "#/definitions/nonNegativeIntegerDefault0" }, |
|
216
|
|
|
|
|
|
|
"uniqueItems": { |
|
217
|
|
|
|
|
|
|
"type": "boolean", |
|
218
|
|
|
|
|
|
|
"default": false |
|
219
|
|
|
|
|
|
|
}, |
|
220
|
|
|
|
|
|
|
"contains": { "$ref": "#" }, |
|
221
|
|
|
|
|
|
|
"maxProperties": { "$ref": "#/definitions/nonNegativeInteger" }, |
|
222
|
|
|
|
|
|
|
"minProperties": { "$ref": "#/definitions/nonNegativeIntegerDefault0" }, |
|
223
|
|
|
|
|
|
|
"required": { "$ref": "#/definitions/stringArray" }, |
|
224
|
|
|
|
|
|
|
"additionalProperties": { "$ref": "#" }, |
|
225
|
|
|
|
|
|
|
"definitions": { |
|
226
|
|
|
|
|
|
|
"type": "object", |
|
227
|
|
|
|
|
|
|
"additionalProperties": { "$ref": "#" }, |
|
228
|
|
|
|
|
|
|
"default": {} |
|
229
|
|
|
|
|
|
|
}, |
|
230
|
|
|
|
|
|
|
"properties": { |
|
231
|
|
|
|
|
|
|
"type": "object", |
|
232
|
|
|
|
|
|
|
"additionalProperties": { "$ref": "#" }, |
|
233
|
|
|
|
|
|
|
"default": {} |
|
234
|
|
|
|
|
|
|
}, |
|
235
|
|
|
|
|
|
|
"patternProperties": { |
|
236
|
|
|
|
|
|
|
"type": "object", |
|
237
|
|
|
|
|
|
|
"additionalProperties": { "$ref": "#" }, |
|
238
|
|
|
|
|
|
|
"propertyNames": { "format": "regex" }, |
|
239
|
|
|
|
|
|
|
"default": {} |
|
240
|
|
|
|
|
|
|
}, |
|
241
|
|
|
|
|
|
|
"dependencies": { |
|
242
|
|
|
|
|
|
|
"type": "object", |
|
243
|
|
|
|
|
|
|
"additionalProperties": { |
|
244
|
|
|
|
|
|
|
"anyOf": [ |
|
245
|
|
|
|
|
|
|
{ "$ref": "#" }, |
|
246
|
|
|
|
|
|
|
{ "$ref": "#/definitions/stringArray" } |
|
247
|
|
|
|
|
|
|
] |
|
248
|
|
|
|
|
|
|
} |
|
249
|
|
|
|
|
|
|
}, |
|
250
|
|
|
|
|
|
|
"propertyNames": { "$ref": "#" }, |
|
251
|
|
|
|
|
|
|
"const": {}, |
|
252
|
|
|
|
|
|
|
"enum": { |
|
253
|
|
|
|
|
|
|
"type": "array", |
|
254
|
|
|
|
|
|
|
"minItems": 1, |
|
255
|
|
|
|
|
|
|
"uniqueItems": true |
|
256
|
|
|
|
|
|
|
}, |
|
257
|
|
|
|
|
|
|
"type": { |
|
258
|
|
|
|
|
|
|
"anyOf": [ |
|
259
|
|
|
|
|
|
|
{ "$ref": "#/definitions/simpleTypes" }, |
|
260
|
|
|
|
|
|
|
{ |
|
261
|
|
|
|
|
|
|
"type": "array", |
|
262
|
|
|
|
|
|
|
"items": { "$ref": "#/definitions/simpleTypes" }, |
|
263
|
|
|
|
|
|
|
"minItems": 1, |
|
264
|
|
|
|
|
|
|
"uniqueItems": true |
|
265
|
|
|
|
|
|
|
} |
|
266
|
|
|
|
|
|
|
] |
|
267
|
|
|
|
|
|
|
}, |
|
268
|
|
|
|
|
|
|
"format": { "type": "string" }, |
|
269
|
|
|
|
|
|
|
"allOf": { "$ref": "#/definitions/schemaArray" }, |
|
270
|
|
|
|
|
|
|
"anyOf": { "$ref": "#/definitions/schemaArray" }, |
|
271
|
|
|
|
|
|
|
"oneOf": { "$ref": "#/definitions/schemaArray" }, |
|
272
|
|
|
|
|
|
|
"not": { "$ref": "#" } |
|
273
|
|
|
|
|
|
|
}, |
|
274
|
|
|
|
|
|
|
"default": {} |
|
275
|
|
|
|
|
|
|
} |
|
276
|
|
|
|
|
|
|
END_JSON |
|
277
|
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
1; |
|
279
|
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
__END__ |
|
281
|
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
=pod |
|
283
|
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
=encoding UTF-8 |
|
285
|
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
=head1 NAME |
|
287
|
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
JSON::Schema::AsType::Draft6 - Role processing draft6 JSON Schema |
|
289
|
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
=head1 VERSION |
|
291
|
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
version 0.4.4 |
|
293
|
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
295
|
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
This role is not intended to be used directly. It is used internally |
|
297
|
|
|
|
|
|
|
by L<JSON::Schema::AsType> objects. |
|
298
|
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
Importing this module auto-populate the Draft4 schema in the |
|
300
|
|
|
|
|
|
|
L<JSON::Schema::AsType> schema cache. |
|
301
|
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
=head1 AUTHOR |
|
303
|
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
Yanick Champoux <yanick@babyl.dyndns.org> |
|
305
|
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
307
|
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
This software is copyright (c) 2024 by Yanick Champoux. |
|
309
|
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
311
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
312
|
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
=cut |