File Coverage

blib/lib/MooseX/JSONSchema/AttributeTrait.pm
Criterion Covered Total %
statement 7 7 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 10 10 100.0


line stmt bran cond sub pod time code
1             package MooseX::JSONSchema::AttributeTrait;
2             our $AUTHORITY = 'cpan:GETTY';
3             # ABSTRACT: Trait for JSON Schema attributes
4             $MooseX::JSONSchema::AttributeTrait::VERSION = '0.001';
5 3     3   3406 use Moose::Role;
  3         9  
  3         25  
6              
7             has json_schema_description => (
8             is => 'ro',
9             isa => 'Str',
10             predicate => 'has_json_schema_description',
11             );
12              
13             has json_schema_type => (
14             is => 'ro',
15             isa => 'Str',
16             predicate => 'has_json_schema_type',
17             );
18              
19             has json_schema_args => (
20             is => 'ro',
21             isa => 'HashRef',
22             lazy_build => 1,
23             );
24 7     7   230 sub _build_json_schema_args {{}}
25              
26             has json_schema_property_data => (
27             is => 'ro',
28             isa => 'HashRef',
29             lazy_build => 1,
30             );
31             sub _build_json_schema_property_data {
32 9     9   41 my ( $self ) = @_;
33             return {
34             type => $self->json_schema_type,
35             description => $self->json_schema_description,
36 9         356 %{$self->json_schema_args},
  9         326  
37             };
38             }
39              
40             1;
41              
42             __END__
43              
44             =pod
45              
46             =head1 NAME
47              
48             MooseX::JSONSchema::AttributeTrait - Trait for JSON Schema attributes
49              
50             =head1 VERSION
51              
52             version 0.001
53              
54             =head1 SYNOPSIS
55              
56             package OtherClass;
57              
58             use Moose;
59             use MooseX::JSONSchema;
60              
61             ...
62              
63             has something => (
64             traits => [qw( MooseX::JSONSchema::AttributeTrait )],
65             json_schema_description => $description,
66             json_schema_type => 'string',
67             predicate => 'has_something',
68             is => 'ro',
69             isa => 'Str',
70             );
71              
72             =head1 SUPPORT
73              
74             Repository
75              
76             https://github.com/Getty/perl-moosex-jsonschema
77             Pull request and additional contributors are welcome
78              
79             Issue Tracker
80              
81             https://github.com/Getty/perl-moosex-jsonschema/issues
82              
83             =cut
84              
85             =for :stopwords cpan testmatrix url bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan
86              
87             =head1 SUPPORT
88              
89             =head2 Source Code
90              
91             The code is open to the world, and available for you to hack on. Please feel free to browse it and play
92             with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull
93             from your repository :)
94              
95             L<https://github.com/Getty/perl-moosex-jsonschema>
96              
97             git clone https://github.com/Getty/perl-moosex-jsonschema.git
98              
99             =head1 AUTHOR
100              
101             Torsten Raudssus <torsten@raudss.us>
102              
103             =head1 COPYRIGHT AND LICENSE
104              
105             This software is copyright (c) 2024 by Torsten Raudssus.
106              
107             This is free software; you can redistribute it and/or modify it under
108             the same terms as the Perl 5 programming language system itself.
109              
110             =cut