| 1 |
use strict; |
| 2 |
use warnings; |
| 3 |
package JSON::Schema::Modern::Vocabulary::MetaData; |
| 4 |
# vim: set ts=8 sts=2 sw=2 tw=100 et : |
| 5 |
# ABSTRACT: Implementation of the JSON Schema Meta-Data vocabulary |
| 6 |
|
| 7 |
our $VERSION = '0.650'; |
| 8 |
|
| 9 |
use 5.020; |
| 10 |
use Moo; |
| 11 |
use strictures 2; |
| 12 |
use stable 0.031 'postderef'; |
| 13 |
use experimental 'signatures'; |
| 14 |
no autovivification warn => qw(fetch store exists delete); |
| 15 |
use if "$]" >= 5.022, experimental => 're_strict'; |
| 16 |
no if "$]" >= 5.031009, feature => 'indirect'; |
| 17 |
no if "$]" >= 5.033001, feature => 'multidimensional'; |
| 18 |
no if "$]" >= 5.033006, feature => 'bareword_filehandles'; |
| 19 |
no if "$]" >= 5.041009, feature => 'smartmatch'; |
| 20 |
no feature 'switch'; |
| 21 |
use JSON::Schema::Modern::Utilities qw(assert_keyword_type annotate_self); |
| 22 |
use namespace::clean; |
| 23 |
|
| 24 |
with 'JSON::Schema::Modern::Vocabulary'; |
| 25 |
|
| 26 |
sub vocabulary ($class) { |
| 27 |
'https://json-schema.org/draft/2019-09/vocab/meta-data' => 'draft2019-09', |
| 28 |
'https://json-schema.org/draft/2020-12/vocab/meta-data' => 'draft2020-12'; |
| 29 |
} |
| 30 |
|
| 31 |
sub evaluation_order ($class) { 5 } |
| 32 |
|
| 33 |
sub keywords ($class, $spec_version) { |
| 34 |
return ( |
| 35 |
qw(title description default), |
| 36 |
$spec_version !~ /^draft[467]\z/ ? 'deprecated' : (), |
| 37 |
$spec_version !~ /^draft[46]\z/ ? qw(readOnly writeOnly) : (), |
| 38 |
$spec_version ne 'draft4' ? 'examples' : (), |
| 39 |
); |
| 40 |
} |
| 41 |
|
| 42 |
sub _traverse_keyword_title ($class, $schema, $state) { |
| 43 |
return if not assert_keyword_type($state, $schema, 'string'); |
| 44 |
return 1; |
| 45 |
} |
| 46 |
|
| 47 |
sub _eval_keyword_title ($class, $data, $schema, $state) { |
| 48 |
annotate_self($state, $schema); |
| 49 |
} |
| 50 |
|
| 51 |
*_traverse_keyword_description = \&_traverse_keyword_title; |
| 52 |
|
| 53 |
*_eval_keyword_description = \&_eval_keyword_title; |
| 54 |
|
| 55 |
sub _traverse_keyword_default { 1 } |
| 56 |
|
| 57 |
*_eval_keyword_default = \&_eval_keyword_title; |
| 58 |
|
| 59 |
sub _traverse_keyword_deprecated ($class, $schema, $state) { |
| 60 |
return assert_keyword_type($state, $schema, 'boolean'); |
| 61 |
} |
| 62 |
|
| 63 |
*_eval_keyword_deprecated = \&_eval_keyword_title; |
| 64 |
|
| 65 |
*_traverse_keyword_readOnly = \&_traverse_keyword_deprecated; |
| 66 |
|
| 67 |
*_eval_keyword_readOnly = \&_eval_keyword_title; |
| 68 |
|
| 69 |
*_traverse_keyword_writeOnly = \&_traverse_keyword_deprecated; |
| 70 |
|
| 71 |
*_eval_keyword_writeOnly = \&_eval_keyword_title; |
| 72 |
|
| 73 |
sub _traverse_keyword_examples ($class, $schema, $state) { |
| 74 |
return assert_keyword_type($state, $schema, 'array'); |
| 75 |
} |
| 76 |
|
| 77 |
*_eval_keyword_examples = \&_eval_keyword_title; |
| 78 |
|
| 79 |
1; |
| 80 |
|
| 81 |
__END__ |
| 82 |
|
| 83 |
=pod |
| 84 |
|
| 85 |
=encoding UTF-8 |
| 86 |
|
| 87 |
=head1 NAME |
| 88 |
|
| 89 |
JSON::Schema::Modern::Vocabulary::MetaData - Implementation of the JSON Schema Meta-Data vocabulary |
| 90 |
|
| 91 |
=head1 VERSION |
| 92 |
|
| 93 |
version 0.650 |
| 94 |
|
| 95 |
I use a linearly-increasing version numbering scheme. No meaning should be |
| 96 |
presumed or inferred from the version being less than 1.0. |
| 97 |
|
| 98 |
=head1 DESCRIPTION |
| 99 |
|
| 100 |
=for Pod::Coverage vocabulary evaluation_order keywords |
| 101 |
|
| 102 |
=for stopwords metaschema |
| 103 |
|
| 104 |
Implementation of the JSON Schema Draft 2020-12 "Meta-Data" vocabulary, indicated in metaschemas |
| 105 |
with the URI C<https://json-schema.org/draft/2020-12/vocab/meta-data> and formally specified in |
| 106 |
L<https://json-schema.org/draft/2020-12/json-schema-validation.html#section-9>. |
| 107 |
|
| 108 |
Support is also provided for |
| 109 |
|
| 110 |
=over 4 |
| 111 |
|
| 112 |
=item * |
| 113 |
|
| 114 |
the equivalent Draft 2019-09 keywords, indicated in metaschemas with the URI C<https://json-schema.org/draft/2019-09/vocab/meta-data> and formally specified in L<https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-02#section-9>. |
| 115 |
|
| 116 |
=item * |
| 117 |
|
| 118 |
the equivalent Draft 7 keywords that correspond to this vocabulary and are formally specified in L<https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-validation-01#section-10>. |
| 119 |
|
| 120 |
=item * |
| 121 |
|
| 122 |
the equivalent Draft 6 keywords that correspond to this vocabulary and are formally specified in L<https://json-schema.org/draft-06/draft-wright-json-schema-validation-01#rfc.section.7>. |
| 123 |
|
| 124 |
=item * |
| 125 |
|
| 126 |
the equivalent Draft 4 keywords that correspond to this vocabulary and are formally specified in L<https://json-schema.org/draft-04/draft-fge-json-schema-validation-00#rfc.section.6>. |
| 127 |
|
| 128 |
=back |
| 129 |
|
| 130 |
=head1 GIVING THANKS |
| 131 |
|
| 132 |
=for stopwords MetaCPAN GitHub |
| 133 |
|
| 134 |
If you found this module to be useful, please show your appreciation by |
| 135 |
adding a +1 in L<MetaCPAN|https://metacpan.org/dist/JSON-Schema-Modern> |
| 136 |
and a star in L<GitHub|https://github.com/karenetheridge/JSON-Schema-Modern>. |
| 137 |
|
| 138 |
=head1 SUPPORT |
| 139 |
|
| 140 |
Bugs may be submitted through L<https://github.com/karenetheridge/JSON-Schema-Modern/issues>. |
| 141 |
|
| 142 |
I am also usually active on irc, as 'ether' at C<irc.perl.org> and C<irc.libera.chat>. |
| 143 |
|
| 144 |
=for stopwords OpenAPI |
| 145 |
|
| 146 |
You can also find me on the L<JSON Schema Slack server|https://json-schema.slack.com> and L<OpenAPI Slack |
| 147 |
server|https://open-api.slack.com>, which are also great resources for finding help. |
| 148 |
|
| 149 |
=head1 AUTHOR |
| 150 |
|
| 151 |
Karen Etheridge <[email protected]> |
| 152 |
|
| 153 |
=head1 COPYRIGHT AND LICENCE |
| 154 |
|
| 155 |
This software is copyright (c) 2020 by Karen Etheridge. |
| 156 |
|
| 157 |
This is free software; you can redistribute it and/or modify it under |
| 158 |
the same terms as the Perl 5 programming language system itself. |
| 159 |
|
| 160 |
Some schema files have their own licence, in share/LICENSE. |
| 161 |
|
| 162 |
=cut |