';
## <?= $method ?> <?= $path ?>
? if ($description) {
<?= $description ?>
? }
### Request
```json
<?= $method ?> <?= $path ?><?= $query ? '?'.$query : '' ?>
<?= $request_body ?>
```
? if ($rule)
$rule->{$name}{$key}) {
* <?= $key ?>: **<?= $rule->{$name}{$key} || '' ?>**
? }
? }
? }
? }
### Response
```json
Status: <?= $code ?>
<?= $response_body ?>
```
---
END
return $tmpl;
}
1;
package Test::Shodo::JSONRPC;
use strict;
use warnings;
use Shodo;
use parent qw/Exporter/;
use JSON qw/from_json/;
use Try::Tiny;
use Test::More;
our @EXPORT = qw/
shodo_document_root
shodo_
req_ok {
my ($req, $note) = @_;
$suzuri->request($req);
my $data = try {
from_json($req->content);
}catch{
warn "$_\n";
};
return unless $data;
return unles
hodo::JSONRPC - Test module using Shodo for JSON-RPC Web API
=head1 SYNOPSIS
use Test::More;
use Plack::Test;
use HTTP::Request;
use JSON qw/to_json/;
use Test::Shodo::JSONRPC;
package Shodo::Suzuri;
use strict;
use warnings;
use Carp qw//;
use Try::Tiny;
use JSON qw/from_json to_json/;
use Data::Validator;
use Clone qw/clone/;
sub new {
my ($class, %args) = @_;
my
pe =~ m!^application/json!) {
my $json_body = to_json(from_json($self->stash->{request_body}, { utf8 => 1 }), { pretty => 1 });
$self->stash->{request_body} = $json_body;
}
ret
e =~ m!^application/json!) {
my $json_body = to_json(from_json($self->stash->{response_body}, { utf8 => 1}), { pretty => 1 });
$self->stash->{response_body} = $json_body;
}
ret