=item Learning JSON Schema
Yancy uses L<JSON Schema|https://json-schema.org> to define and annotate
the database schema. You can read more L<from the JSON Schema tutorial|https://json-schema.org/lea
s );
use Scalar::Util qw( blessed );
use Mojo::JSON::Pointer;
use Mojo::JSON qw( to_json );
use Mojo::Util qw( xml_escape );
use Carp qw( carp );
use JSON::Validator;
our @EXPORT_OK = qw( load_backen
d curry currym copy_inline_refs match derp fill_brackets
is_type order_by is_format json_validator );
#pod =sub load_backend
#pod
#pod my $backend = load_backend( $backend_url, $schema );
#po
erence
#pod with a backend name and optional argument. The C<$schema> hash is
#pod the configured JSON schema for this backend.
#pod
#pod A backend URL should begin with a name followed by a colon. Th
ncy/auth/unauthorized',
status => 401,
);
$c->respond_to(
json => {},
html => {},
);
return undef;
}
}
sub has_role {
my (
base';
use Scalar::Util qw( blessed );
use Yancy::Util qw( is_type is_format );
use Mojo::JSON qw( encode_json );
has schema => sub { {} };
sub collections {
require Carp;
Carp::carp( '"colle
all backends, and may never be supported by
#pod some. Postgres has array columns and JSON fields. MySQL has JSON fields.
#pod The L<Yancy::Util/match> function matches against Perl data structures.
ise.
#pod
#pod Currently the values of the data cannot be references, only simple
#pod scalars or JSON booleans.
#pod
#pod =cut
sub set { ... }
#pod =head2 set_p
#pod
#pod my $promise = $be->set
/ATTRIBUTES>, these
#pod options may be given:
#pod
#pod =over
#pod
#pod =item schema
#pod
#pod A JSON schema configuration. By default, the information from
#pod L</read_schema> will be merged with t
e, json_schema => $data );
}
$self->_schema->{$name} = $data;
return $self;
}
#pod =method json_schema
#pod
#pod Get the JSON Schema for every attached schema.
#pod
#pod =cut
sub json_sc
!@names ) {
@names = $self->schema_names;
}
return {
map { $_ => $self->schema( $_ )->json_schema } @names
};
}
#pod =method schema_names
#pod
#pod Get a list of all the schema names.
#
aste::Service::perlbot;
use Mojo::Base 'Mojolicious::Command::nopaste::Service';
use Mojo::JSON qw/decode_json/;
use Getopt::Long;
our $VERSION = '0.007';
# ABSTRACT: Pastes stuff to https://perl.b
s) {
say "Failed to get channels, try again later.";
exit 1;
}
my $response = decode_json $tx->res->body;
my $output="Channels supported by perl.bot, all values subject to change.\n---
->is_success) {
say "Failed to get languages, try again later.";
}
my $response = decode_json $tx->res->body;
my $output="Languages supported by perl.bot\n-----------------------------\n";
ier';
use utf8;
use Web::MarketReceipt;
use Carp;
use Crypt::OpenSSL::RSA;
use MIME::Base64;
use JSON::XS;
subtype 'Crypt::OpenSSL::RSA' => as 'Object' => where { $_->isa('Crypt::OpenSSL::RSA') };
c
my $raw_json = decode_json $signed_data;
Web::MarketReceipt->new(
is_success => $verification_result ? 1 : 0,
store => 'GooglePlay',
raw => $raw_json,
ists $raw_json->{orders} ? (
orders => [ map { $self->_order2hash($_) } @{ $raw_json->{orders} } ],
) : (
orders => [ $self->_order2hash($raw_json) ],
- https://perlbot.pl/
our $VERSION = '0.005';
use parent 'App::Nopaste::Service';
use JSON::PP qw/decode_json/;
sub run {
my ($self, %arg) = @_;
my $ua = LWP::UserAgent->new;
if ($arg
return (0, "Failed to get channels, try again later.\n");
}
my $response = decode_json $res->decoded_content;
my $output="Channels supported by perl.bot, all values subject to c
($res->is_success()) {
my $content = $res->decoded_content;
my $data = decode_json $content;
return (1, $data->{url});
} else {
return (0, "Paste failed"
}
undef;
}
# dzil also wants to get abstract for main module to put in dist's
# META.{yml,json}
sub before_build {
my $self = shift;
my $name = $self->zilla->name;
my $class = $name
package Test::HTTP::MockServer::Once::REST;
use strict;
use warnings;
use JSON::XS;
sub new {
my ($class) = shift;
$class = ref $class || $class;
my %dispatch = @_;
return bless { d =
if ($input_content && $input_ct && $input_ct eq 'application/json') {
eval {
$input_data = decode_json $req->content;
};
if ($@) {
&& $a eq 'application/json') {
eval {
my $out = encode_json $return_data;
$res->header('Content-type', 'application/json');
form_for( 'people' );
#pod
#pod =head1 DESCRIPTION
#pod
#pod The Form plugins generate forms from JSON schemas. Plugin and
#pod application developers can use the form plugin API to make forms, and
#p
#pod
#pod =over
#pod
#pod =item type
#pod
#pod The type of the input field to create. One of the JSON schema types.
#pod See L<Yancy::Guides::Schema/Types> for details on the supported
#pod types.
#p
ormat
#pod
#pod For C<string> types, the format the string should take. One of the
#pod supported JSON schema formats, along with some additional ones. See
#pod L<Yancy::Guides::Schema/Types> for deta
::MarketReceipt::Verifier';
use utf8;
use Carp;
no Mouse;
use Web::MarketReceipt;
use Furl;
use JSON::XS;
use Try::Tiny;
use MIME::Base64;
sub verify {
my ($self, %args) = @_;
my $environm
receipts/
my $res_json = $self->_send_request(
environment => $environment,
hash => $hash,
opts => $args{opts},
);
if ($res_json->{status} == 21007)
'Sandbox';
$res_json = $self->_send_request(
environment => $environment,
hash => $hash,
);
}
my $raw_json = $res_json->{receipt};
Web::Mar
S
Test and debug Apache2 mod_perl handlers without running an apache server.
=head1 USAGE
use JSON;
use Test::More;
sub catch_stdout { ... }
sub unescapeURIString { ... }
sub test_http_hand
ders_out->{'Content-Type'} eq $ct, "Content-Type: '$ct'");
my $result = $ct =~ /json/i ? from_json(unescapeURIString($body)) : $body;
ok(Compare($result, $exp_res), "body");
}
tp_handler('My::Apache::Request::handler', { redirect => "https://localhost/" }, 55, 'application/json', login => 'mylogin', password => 'mypasswd');
=head1 DESCRIPTION
B<Apache2::Dummy::RequestRec>
calar::Util qw( blessed );
use Mojo::JSON qw( true false );
use Mojo::Util qw( url_escape );
use Sys::Hostname qw( hostname );
use Yancy::Util qw( derp currym json_validator load_backend );
has monik
=> $spec,
default_response_name => '_Error',
validator => json_validator(),
} );
$_->to(format => 'json') for (@{$openapi->route->children});
$app->helper( 'yancy.openapi'
format => 'json',
};
}
else {
# per-schema - GET = "list"
return {
action => 'list',
format => 'json',
0';
use strict;
use warnings;
use Moose;
use MooseX::NonMoose;
use MooseX::Params::Validate;
use JSON;
use HTTP::Request::Common qw '';
extends 'REST::Client';
has host => (
is => 'ro',
isa =>
shift;
return decode_json $self->elab_get("items_types/");
}
sub get_item_types {
return get_items_types(@_);
}
sub get_status {
my $self = shift;
return decode_json $self->elab_get("stat
hift;
my (%args) = validated_hash(
\@_,
link => { isa => 'Str' },
);
return decode_json $self->elab_post("experiments/$id", $self->buildQuery(%args));
}
sub add_link_to_item {
my $
the error',
# Description of path field in OpenAPI error object
'OpenAPI error path' => 'JSON pointer to the input data where the error occur',
);
1;
__END__
=pod
=head1 NAME
Yancy::I18N
logout_route => $self->logout_route->render,
);
$c->respond_to(
json => {},
html => {},
);
return undef;
};
}
around register => sub
specifying the run details.
In principle, several configuration file formats are available: XML, JSON,
YAML. However, forty-two was designed with YAML in mind. See the C<test>
directory of the distri
#pod
#pod =cut
use Mojo::Base '-role';
use List::Util qw( any );
use DBI ':sql_types';
use Mojo::JSON qw( true );
requires 'dbh', 'table_info';
# only specify non-string - code-ref called with colu
specifying the run details.
In principle, several configuration file formats are available: XML, JSON,
YAML. However, leel was designed with YAML in mind. See the C<test> directory
of the distributio