ncy/auth/unauthorized',
status => 401,
);
$c->respond_to(
json => {},
html => {},
);
return undef;
};
}
1;
__END__
=pod
=hea
handlers also gives you a built-in JSON API for your
#pod website. Any user agent that requests JSON will get JSON instead of
#pod HTML. For full details on how JSON clients are detected, see
#pod L<M
ALSO
#pod
#pod L<Yancy>
#pod
#pod =cut
use Mojo::Base 'Mojolicious::Controller';
use Mojo::JSON qw( to_json );
use Yancy::Util qw( derp is_type );
use POSIX qw( ceil );
#pod =method schema
#pod
#pod
words).
#pod
#pod =cut
sub clean_item {
my ( $self, $item ) = @_;
my $props = $self->schema->json_schema->{properties};
my @keep_props = grep { !$props->{$_} || ($props->{$_}{format}//'') ne 'p
hen the user is not logged
#pod in.
#pod
#pod =head2 yancy/auth/unauthorized.json.ep
#pod
#pod This template renders a JSON object with an "errors" array explaining
#pod the error.
#pod
#pod =head2 la
ost-often appears when the user is not logged
in.
=head2 yancy/auth/unauthorized.json.ep
This template renders a JSON object with an "errors" array explaining
the error.
=head2 layouts/yancy/auth.h
add the following code.
use JSON qw(to_json from_jsom);
$Dancer2::Session::DatabasePlugin::FREEZE=\&to_json;
$Dancer2::Session::DatabasePlugin::THAW=\&from_json;
$Dancer2::Session::Databas
eeded. If validation fails, this helper will throw an
#pod exception with an array reference of L<JSON::Validator::Error> objects.
#pod See L<the validate helper|/yancy.validate> and L<the filter appl
/comment/:id' => sub {
#pod eval { $c->yancy->set( "comment", $c->stash( 'id' ), $c->req->json ) };
#pod if ( $@ ) {
#pod return $c->render( status => 400, errors => $@ );
eeded. If validation fails, this helper will throw an
#pod exception with an array reference of L<JSON::Validator::Error> objects.
#pod See L<the validate helper|/yancy.validate> and L<the filter appl
ojolicious::Controller>
#pod
#pod =cut
use Mojo::Base 'Mojolicious::Controller';
use Mojo::JSON qw( to_json );
use Yancy::Util qw( derp );
#pod =method list
#pod
#pod List the items in a schema. The
-not_bool' } = $key;
}
else {
die "Sorry type '" .
to_json( $type ) .
"' is not handled yet, only string|number|integer|boolean is supported
tem is extracted from the OpenAPI input, under parameter name
#pod C<newItem>, and must be a hash/JSON "object". It will be filtered by
#pod filters conforming with L<Mojolicious::Plugin::Yancy/yancy.
exists,
#pod that will be called, and must return the initial JSON schema for Yancy.
#pod
#pod A very useful possibility is for that JSON schema to just contain
#pod C<<{ 'x-ignore' => 1 }>>.
#pod
#p
lar::Util qw( looks_like_number blessed );
use Mojo::Loader qw( load_class );
use Mojo::JSON qw( true encode_json );
BEGIN {
eval { require DBIx::Class; DBIx::Class->VERSION( 0.082842 ); 1 }
$self->normalize( $schema_name, $params );
die "No refs allowed in '$schema_name': " . encode_json $params
if grep ref && ref ne 'SCALAR', values %$params;
my $created = $self->driver-
nd';
use Role::Tiny 'with';
use Scalar::Util qw( blessed looks_like_number );
use Mojo::JSON qw( true encode_json );
use Carp qw( croak );
use Yancy::Util qw( is_type is_format );
with 'Yancy::Backen
oken', $token ) },
)
->then( sub {
my ( $tx ) = @_;
my $login = $tx->res->json( '/login' );
if ( !$login ) {
$c->render( text => 'Error getting Github login
mas are configured using L<JSON Schema|http://json-schema.org>.
The JSON Schema defines what fields (properties) an item has, and what
type of data those field have. The JSON Schema also can define
co
even an C<example> value. For more information on
what can be defined, see L<the docs on JSON Schema|http://json-schema.org>.
=head2 Yancy Generated Schema
By default, Yancy will read your database
ger C<id> and two
strings, C<name> (not nullable) and C<email> (nullable)), Yancy will
generate a JSON schema that looks like this:
schema => {
people => {
required => [ 'name
scans your database to determine what kind of data is inside, but
Yancy also accepts a L<JSON Schema|http://json-schema.org> to add more
information about your data. You can add descriptions, examples
!$self->isa( scalar caller ) ) {
return $self->{data};
}
return $self;
}
sub TO_JSON {
my ( $self ) = @_;
return $self->{data};
}
#pod =attr schema
#pod
#pod The L<Yancy::Mo
en enhanced to support everything that
Yancy::Controller::Yancy::API could do (like searching and JSON in the
request body).
To get back to the old API, set C<editor.default_controller> to
'Yancy::Co
des::Model>, L<Yancy::Model>
#pod
#pod =cut
use Mojo::Base -base;
use Mojo::JSON qw( true false );
use Yancy::Util qw( json_validator is_type derp );
#pod =attr model
#pod
#pod The L<Yancy::Model> o
=> sub { die 'name is required' };
#pod =attr json_schema
#pod
#pod The JSON Schema for this schema.
#pod
#pod =cut
has json_schema => sub { die 'json_schema is required' };
sub _backend { shift->
sub new {
my ( $class, @args ) = @_;
my $self = $class->SUPER::new( @args );
$self->_check_json_schema;
return $self;
}
#pod =method id_field
#pod
#pod The ID field for this schema. Either a
r_id';
my $user_id = $c->stash( 'user_id' );
if ( eval { $c->req->json } ) {
$c->req->json->{ $user_id_field } = $user_id;
}
else {
$c->req->par
to Local::Test
use Mojo::Base '-base';
use List::Util qw( max );
use Mojo::JSON qw( true false from_json to_json encode_json );
use Mojo::File qw( path );
use Storable qw( dclone );
use Role::Tiny qw
path ) = $url =~ m{^[^:]+://[^/]+(?:/(.+))?$};
if ( $path ) {
%DATA = %{ from_json( path( ( $ENV{MOJO_HOME} || () ), $path )->slurp ) };
}
}
$schema //= \%Local::Te
L<Mojo::Pg>, L<Yancy>
#pod
#pod =cut
use Mojo::Base 'Yancy::Backend::MojoDB';
use Mojo::JSON qw( encode_json );
use Scalar::Util qw( blessed );
BEGIN {
eval { require Mojo::Pg; Mojo::Pg->VERSION
s;
use version;
use Carp;
use English qw/ -no_match_vars /;
use IO::Prompt qw/prompt/;
use JSON qw/decode_json/;
use WWW::Mechanize;
use Path::Tiny;
our $VERSION = version->new('0.7.7');
extends 'Gr
tus, ") accessing $url$start\n";
last;
}
my $response = eval { decode_json $mech->content };
if ( !$response ) {
die $@ || "Error occured processing sta
s;
use version;
use Carp;
use English qw/ -no_match_vars /;
use IO::Prompt qw/prompt/;
use JSON qw/decode_json/;
use WWW::Mechanize;
use Path::Tiny;
our $VERSION = version->new('0.7.7');
extends 'Gr
cket.org/1.0/user/repositories";
@ARGV = @argv;
$mech->get($url);
my $repos = decode_json $mech->content;
for my $repo ( @$repos ) {
$repos{$repo->{name}} = Group::Git::Repo->
horized result
if ( grep { $_ eq 'api' } @{ $c->req->url->path } ) {
# Render JSON unauthorized response
$c->render(
handler => 'openapi', # XXX This st