APISchema

 view release on metacpan or  search on metacpan

META.json  view on Meta::CPAN

      },
      "runtime" : {
         "requires" : {
            "Class::Accessor::Lite" : "0",
            "Class::Accessor::Lite::Lazy" : "0",
            "Class::Load" : "0",
            "HTML::Escape" : "0",
            "HTTP::Message" : "0",
            "Hash::Merge::Simple" : "0",
            "JSON::Pointer" : "0",
            "JSON::XS" : "0",
            "List::MoreUtils" : "0",
            "Path::Class" : "0",
            "Plack" : "0",
            "Router::Simple" : "0",
            "Text::Markdown::Hoedown" : "0",
            "Text::MicroTemplate" : "0",
            "Text::MicroTemplate::DataSection" : "0",
            "Text::MicroTemplate::Extended" : "0",
            "URI::Escape" : "0",
            "URL::Encode" : "0",

META.yml  view on Meta::CPAN

  Plack::Middleware::APISchema::ResponseValidator:
    file: lib/Plack/Middleware/APISchema/ResponseValidator.pm
requires:
  Class::Accessor::Lite: '0'
  Class::Accessor::Lite::Lazy: '0'
  Class::Load: '0'
  HTML::Escape: '0'
  HTTP::Message: '0'
  Hash::Merge::Simple: '0'
  JSON::Pointer: '0'
  JSON::XS: '0'
  List::MoreUtils: '0'
  Path::Class: '0'
  Plack: '0'
  Router::Simple: '0'
  Text::Markdown::Hoedown: '0'
  Text::MicroTemplate: '0'
  Text::MicroTemplate::DataSection: '0'
  Text::MicroTemplate::Extended: '0'
  URI::Escape: '0'
  URL::Encode: '0'

cpanfile  view on Meta::CPAN

requires 'perl', '5.008001';

requires 'Router::Simple';
requires 'Plack';
requires 'JSON::XS';
requires 'JSON::Pointer';
requires 'Path::Class';
requires 'Class::Load';
requires 'Class::Accessor::Lite';
requires 'Class::Accessor::Lite::Lazy';
requires 'List::MoreUtils';
requires 'Hash::Merge::Simple';
requires 'URL::Encode';
requires 'HTML::Escape';
requires 'Text::MicroTemplate';

lib/APISchema/Generator/Markdown/Formatter.pm  view on Meta::CPAN

use strict;
use warnings;

# core
use Exporter qw(import);
our @EXPORT = qw(type json pretty_json code restriction desc anchor method methods content_type http_status http_status_code);

# cpan
use HTTP::Status qw(status_message);
use URI::Escape qw(uri_escape_utf8);
use JSON::XS ();
my $JSON = JSON::XS->new->canonical(1);

use constant +{
    RESTRICTIONS => [qw(required max_items min_items max_length min_length maximum minimum pattern)],
    SHORT_DESCRIPTION_LENGTH => 100,
};

sub type ($); # type has recursive call

sub type ($) {
    my $def = shift;

lib/APISchema/Generator/Markdown/Formatter.pm  view on Meta::CPAN

        }
    } elsif (ref $x) {
        $x = $JSON->encode($x);
    } else {
        $x = $JSON->encode([$x]);
        $x =~ s/^\[(.*)\]$/$1/;
    }
    return $x;
}

my $PRETTY_JSON = JSON::XS->new->canonical(1)->indent(1)->pretty(1);
sub pretty_json ($) {
    my $x = shift;
    if (ref $x) {
        $x = $PRETTY_JSON->encode($x);
    } else {
        $x = $PRETTY_JSON->encode([$x]);
        $x =~ s/^\[\s*(.*)\s*\]\n$/$1/;
    }
    return $x;
}

lib/APISchema/JSON.pm  view on Meta::CPAN

package APISchema::JSON;
use strict;
use warnings;

use Exporter 'import';
our @EXPORT = qw(encode_json_canonical);

use JSON::XS;

my $json = JSON::XS->new->utf8->canonical(1);

sub encode_json_canonical {
    my ($value) = @_;
    $json->encode($value);
}

1;

lib/APISchema/Validator/Decoder.pm  view on Meta::CPAN

package APISchema::Validator::Decoder;
use strict;
use warnings;

# cpan
use JSON::XS qw(decode_json);
use URL::Encode qw(url_params_mixed);
use Class::Accessor::Lite ( new => 1 );

sub perl {
    my ($self, $body) = @_;
    return $body;
}

my $JSON = JSON::XS->new->utf8;
sub json {
    my ($self, $body) = @_;
    return $JSON->decode($body);
}

sub url_parameter {
    my ($self, $body) = @_;
    return undef unless defined $body;
    return url_params_mixed($body, 1);
}

t/APISchema-Validator.t  view on Meta::CPAN

package t::Plack::Middleware::APISchema::ResponseValidator;
use lib '.';
use t::test;
use t::test::fixtures;
use JSON::XS qw(encode_json);

sub _require : Test(startup => 1) {
    use_ok 'APISchema::Validator';
}

sub instantiate : Tests {
    subtest 'For request' => sub {
        my $validator = APISchema::Validator->for_request;
        isa_ok $validator, 'APISchema::Validator';
        is $validator->validator_class, 'Valiemon';

t/Plack-Middleware-APISchema-RequestValidator.t  view on Meta::CPAN

package t::Plack::Middleware::APISchema::RequestValidator;
use lib '.';
use t::test;
use t::test::fixtures;
use Plack::Test;
use HTTP::Request::Common;
use HTTP::Status qw(:constants);
use JSON::XS qw(encode_json);

sub _require : Test(startup => 1) {
    my ($self) = @_;

    use_ok 'Plack::Middleware::APISchema::RequestValidator';
}

sub instantiate : Tests {
    my $schema = APISchema::Schema->new;
    my $middleware = Plack::Middleware::APISchema::RequestValidator->new(schema => $schema);

t/Plack-Middleware-APISchema-ResponseValidator.t  view on Meta::CPAN

package t::Plack::Middleware::APISchema::ResponseValidator;
use lib '.';
use t::test;
use t::test::fixtures;
use Plack::Test;
use Plack::Request;
use HTTP::Request::Common;
use JSON::XS qw(encode_json);

sub _require : Test(startup => 1) {
    my ($self) = @_;

    use_ok 'Plack::Middleware::APISchema::ResponseValidator';
}

sub instantiate : Tests {
    my $schema = APISchema::Schema->new;
    my $middleware = Plack::Middleware::APISchema::ResponseValidator->new(schema => $schema);



( run in 0.346 second using v1.01-cache-2.11-cpan-4d50c553e7e )