ackage JSON::Schema::Generator;
use 5.008001;
use strict;
use warnings;
our $VERSION = "0.01";
use JSON::Schema::Generator::Handler::Array;
use JSON::Schema::Generator::Handler::Atom;
use JSON::Sche
ma::Generator::Handler::Maybe::Lifted;
use JSON::Schema::Generator::Handler::Object;
use JSON::Schema::Generator::Handler::Union;
use JSON::TypeInference;
sub new {
my ($class) = @_;
return bless
b generate {
my ($self) = @_;
my $inferred_type = JSON::TypeInference->infer($self->{learned_data});
return {
'$schema' => 'http://json-schema.org/draft-04/schema#',
title => 'TO
package JSON::Schema::Generator::Handler::Maybe::Lifted;
use strict;
use warnings;
sub process {
my($class, $maybe_type, $examples, $dispatch) = @_;
my $entity_examples = [ grep { $maybe_type->t
package JSON::Schema::Generator::Handler::Union;
use strict;
use warnings;
sub process {
my ($class, $union_type, $examples, $dispatch) = @_;
return +{
type => [ map { $_->name } @{$union
package JSON::Schema::Generator::Handler::Atom;
use strict;
use warnings;
sub process {
my ($class, $atom_type, $examples, $dispatch) = @_;
return +{
type => $atom_type->name,
($atom_typ
e->isa('JSON::TypeInference::Type::Unknown') ? () : (example => $examples->[0])),
};
}
1;
package JSON::Schema::Generator::Handler::Object;
use strict;
use warnings;
use List::MoreUtils qw(uniq);
sub process {
my ($class, $object_type, $examples, $dispatch) = @_;
my $examples_by_pro
package JSON::Schema::Generator::Handler::Array;
use strict;
use warnings;
sub process {
my ($class, $array_type, $examples, $dispatch) = @_;
return +{
type => $array_type->name,
items