package Test::JsonAPI::Autodoc;
use 5.008005;
use strict;
use warnings;
use parent qw/Exporter/;
use Carp;
use Test::More ();
use Scope::Guard;
use LWP::UserAgent;
use Test::JsonAPI::Autodoc::Markdown
;
use Test::JsonAPI::Autodoc::Request;
use Test::JsonAPI::Autodoc::Response;
our @EXPORT = qw/
describe
http_ok
plack_ok
set_documents_path
set_template
/;
our $VERSION = "0.22";
test($description => $coderef);
if ($result && $results && $ENV{TEST_JSONAPI_AUTODOC}) {
my $markdown = Test::JsonAPI::Autodoc::Markdown->new($output_path, $template);
$markdown->
package Test::JsonAPI::Autodoc::Response;
use strict;
use warnings;
use utf8;
use JSON;
sub new {
my ($class) = @_;
bless {
}, $class;
}
sub parse {
my ($self, $res) = @_;
my $
my $content_type = $res->content_type;
if ($content_type =~ m!^application/json!) {
$body = to_json(from_json($res->decoded_content, { utf8 => 1 }), { pretty => 1, canonical => 1 });
}
e Test::JsonAPI::Autodoc::Markdown;
use strict;
use warnings;
use utf8;
use Data::Section::Simple;
use Time::Piece;
use Text::Xslate qw(mark_raw);
use Text::Xslate::Bridge::Star;
use Test::JsonAPI::Au
nerate {
my ($self, $description, $results, $first_time) = @_;
my $document_path = Test::JsonAPI::Autodoc::Path->document_path($self->{output_path});
my $vpath = Data::Section::Simple->n
: $tx->render('document.json.tx', $vars);
print $fh $rendered;
close $fh;
}
1;
__DATA__
@@ document.json.tx
: if $generated_at {
generated at: <: $generated_at
package Test::JsonAPI::Autodoc::Request;
use strict;
use warnings;
use utf8;
use Carp;
use JSON;
use URL::Encode qw/url_params_flat/;
sub new {
my ($class) = @_;
bless {
}, $class;
}
su
ontent_type;
my $is_json = 0;
if ($content_type =~ m!^application/json!) {
$body = to_json(from_json($req->decoded_content), { pretty => 1 });
$is_json = 1;
}
my $tar
method => $req->method,
parameters => $self->_parse_request_parameters($body, $is_json, $param_description),
path => $req->uri->path,
query => $req->uri-