package MooseX::JSONSchema;
our $AUTHORITY = 'cpan:GETTY';
# ABSTRACT: Adding JSON Schema capabilities to your Moose class
$MooseX::JSONSchema::VERSION = '0.001';
use Moose::Exporter;
use Carp qw( cro
boolean ),
qw( json_schema_id json_schema_title json_schema_schema ),
],
base_class_roles => ['MooseX::JSONSchema::Role'],
class_metaroles => {
class => ['MooseX::JSONSchema::MetaClassTr
MooseX::JSONSchema::MetaClassTrait'],
},
);
sub json_schema_id { shift->json_schema_id(shift) }
sub json_schema_title { shift->json_schema_title(shift) }
sub json_schema_schema { shift->json_schema
seX::JSONSchema::Role;
our $AUTHORITY = 'cpan:GETTY';
# ABSTRACT: Role for classes who have JSON Schema
$MooseX::JSONSchema::Role::VERSION = '0.001';
use Moose::Role;
use JSON::MaybeXS;
sub json_sche
)
} keys %{$self->meta->json_schema_properties},
};
}
sub json_schema_data_json {
my ( $self, %args ) = @_;
my $data = $self->json_schema_data;
my $json = JSON::MaybeXS->new(
utf8 =>
canonical => 1,
%args,
);
return $json->encode($data);
}
1;
__END__
=pod
=head1 NAME
MooseX::JSONSchema::Role - Role for classes who have JSON Schema
=head1 VERSION
version 0.001
=fo
ooseX::JSONSchema::AttributeTrait;
our $AUTHORITY = 'cpan:GETTY';
# ABSTRACT: Trait for JSON Schema attributes
$MooseX::JSONSchema::AttributeTrait::VERSION = '0.001';
use Moose::Role;
has json_schema
a => 'Str',
predicate => 'has_json_schema_description',
);
has json_schema_type => (
is => 'ro',
isa => 'Str',
predicate => 'has_json_schema_type',
);
has json_schema_args => (
is => 'ro',
',
lazy_build => 1,
);
sub _build_json_schema_args {{}}
has json_schema_property_data => (
is => 'ro',
isa => 'HashRef',
lazy_build => 1,
);
sub _build_json_schema_property_data {
my ( $sel
::JSONSchema::MetaClassTrait;
our $AUTHORITY = 'cpan:GETTY';
# ABSTRACT: Trait for meta classes having a JSON Schema
$MooseX::JSONSchema::MetaClassTrait::VERSION = '0.001';
use Moose::Role;
use JSON::
s json_schema_id => (
is => 'rw',
isa => 'Str',
lazy_build => 1,
);
sub _build_json_schema_id {
my ( $self ) = @_;
my $class = lc($self->name);
$class =~ s/::/./g;
return 'https://json-s
'.$class.'.schema.json';
}
has json_schema_schema => (
is => 'rw',
isa => 'Str',
lazy_build => 1,
);
sub _build_json_schema_schema {
my ( $self ) = @_;
return 'https://json-schema.org/draft