package JSON::Schema::ToJSON;
use strict;
use warnings;
use B;
use Mojo::Base -base;
use Cpanel::JSON::XS;
use String::Random;
use Hash::Merge qw/ merge /;
use Data::Fake qw/ Core Names Text Dates /
/;
our $VERSION = '0.20';
has _validator => sub {
$ENV{JSON_VALIDATOR_RECURSION_LIMIT} = shift->max_depth;
require JSON::Validator;
JSON::Validator->new
};
has _str_rand => sub { String::Rand
0 };
sub json_schema_to_json {
my ( $self,%args ) = @_;
my $schema = $args{schema}; # an already parsed JSON schema
if ( ! $schema ) {
$schema = $args{schema_str} # an unparsed JSON schema
use Mojolicious::Lite; # "strict", "warnings", "utf8" and Perl 5.10 features
use JSON::Schema::ToJSON;
use Mojo::JSON;
my $spec_uri = shift || die "Need a spec URI: $0 <spec_uri> <base_path> [<ex
a = $spec->{'responses'}{$response}{schema};
$data = JSON::Schema::ToJSON->new(
example_key => 'x-example',
)->json_schema_to_json( schema => $schema );
$c->stash( status => $response
);
}
}
$data->{messages} = delete $data->{errors} if $data->{errors};
return Mojo::JSON::encode_json( $data );
},
};
app->start;
package JSON::Schema::ToJSON;
use strict;
use warnings;
use B;
use Mojo::Base -base;
use Cpanel::JSON::XS;
use String::Random;
use Hash::Merge qw/ merge /;
use Data::Fake qw/ Core Names Text Dates /
/;
our $VERSION = '0.20';
has _validator => sub {
$ENV{JSON_VALIDATOR_RECURSION_LIMIT} = shift->max_depth;
require JSON::Validator;
JSON::Validator->new
};
has _str_rand => sub { String::Rand
0 };
sub json_schema_to_json {
my ( $self,%args ) = @_;
my $schema = $args{schema}; # an already parsed JSON schema
if ( ! $schema ) {
$schema = $args{schema_str} # an unparsed JSON schema