APISchema
view release on metacpan or search on metacpan
lib/Plack/App/APISchema/Document.pm view on Meta::CPAN
package Plack::App::APISchema::Document;
use strict;
use warnings;
use parent qw(Plack::Component);
use Plack::Util::Accessor qw(schema);
use Text::Markdown::Hoedown qw(markdown);
use Text::MicroTemplate qw(encoded_string);
use Text::MicroTemplate::DataSection qw(render_mt);
use Encode qw(encode_utf8);
use APISchema::Generator::Markdown;
sub call {
my ($self, $env) = @_;
lib/Plack/App/APISchema/MockServer.pm view on Meta::CPAN
package Plack::App::APISchema::MockServer;
use strict;
use warnings;
use parent qw(Plack::Component);
use Plack::Util::Accessor qw(schema);
use Plack::Request;
use Encode qw(encode_utf8);
use APISchema::JSON;
use APISchema::Generator::Router::Simple;
use APISchema::Generator::Markdown::ResourceResolver;
use APISchema::Generator::Markdown::ExampleFormatter;
lib/Plack/Middleware/APISchema/RequestValidator.pm view on Meta::CPAN
package Plack::Middleware::APISchema::RequestValidator;
use strict;
use warnings;
use parent qw(Plack::Middleware);
use HTTP::Status qw(:constants);
use Plack::Util::Accessor qw(schema validator);
use Plack::Request;
use APISchema::Generator::Router::Simple;
use APISchema::Validator;
use APISchema::JSON;
use constant DEFAULT_VALIDATOR_CLASS => 'Valiemon';
sub call {
lib/Plack/Middleware/APISchema/ResponseValidator.pm view on Meta::CPAN
package Plack::Middleware::APISchema::ResponseValidator;
use strict;
use warnings;
use parent qw(Plack::Middleware);
use Plack::Util ();
use Plack::Util::Accessor qw(schema validator);
use Plack::Response;
use APISchema::Generator::Router::Simple;
use APISchema::Validator;
use APISchema::JSON;
use constant DEFAULT_VALIDATOR_CLASS => 'Valiemon';
sub call {
script/generate_markdown_document.pl view on Meta::CPAN
#!/usr/bin/env perl
use strict;
use warnings;
use Encode qw(encode_utf8);
BEGIN {
# cpan
use Path::Class qw(file);
my $Root = file(__FILE__)->dir->parent->resolve->absolute;
unshift @INC, $Root->subdir('lib').q();
}
# lib
use APISchema::DSL;
use APISchema::Generator::Markdown;
unless ($ARGV[0]) {
print <<EOM;
Usage: $0 <file>
t/APISchema-Generator-Router-Simple.t view on Meta::CPAN
sub generate_custom_router : Tests {
my $generator = APISchema::Generator::Router::Simple->new(
router_class => 'Test::Router::Simple',
);
my $schema = APISchema::Schema->new;
my $router = $generator->generate_router($schema);
isa_ok $router, 'Test::Router::Simple';
}
package Test::Router::Simple;
use parent qw(Router::Simple);
package t::APISchema::Generator::Router::Simple;
t/fixtures/family.def view on Meta::CPAN
};
resource target => {
type => 'object',
description => 'Target of retrieving information',
properties => {
name => { '$ref' => '#/resource/person/properties/name' },
},
};
resource parent => {
'$ref' => '#/resource/target',
description => 'Target of retrieving/defining children',
example => { name => 'Bob' },
};
resource people => {
type => 'array',
description => 'Some people',
items => {
'$ref' => '#/resource/person',
t/fixtures/family.def view on Meta::CPAN
destination => {},
request => { parameter => 'target' },
response => 'person',
};
PUT '/child' => {
title => 'Child PUT API',
description => 'Add a child to a person',
destination => {},
request => {
parameter => 'parent',
body => 'person',
},
response => 'result',
};
GET '/children' => {
title => 'Children GET API',
description => 'Retrieve children of a person',
destination => {},
request => { parameter => 'parent' },
response => 'people',
};
package t::test;
use strict;
use warnings;
use Path::Class;
use lib file(__FILE__)->dir->parent->subdir('lib')->stringify;
use lib lib => 't/lib' => glob 'modules/*/lib';
sub import {
my ($class) = @_;
strict->import;
warnings->import;
my ($package, $file) = caller;
my $code = qq[
package $package;
use strict;
use warnings;
use parent qw(Test::Class);
use Test::More;
use Test::Fatal qw(lives_ok dies_ok exception);
use Test::Deep;
use Test::Deep::JSON;
END { $package->runtests }
];
eval $code;
die $@ if $@;
t/test/InheritedDocument.pm view on Meta::CPAN
package t::test::InheritedDocument;
use strict;
use warnings;
use parent qw(Plack::App::APISchema::Document);
1;
__DATA__
@@ template.mt
? my ($title, $body) = @_;
<!DOCTYPE html>
<html>
<head>
<title><?= $title ?></title>
<style>* { color: pink; }</style>
( run in 0.306 second using v1.01-cache-2.11-cpan-4d50c553e7e )