no
autovivification
warn
=>
qw(fetch store exists delete)
;
use
if
"$]"
>= 5.022,
experimental
=>
're_strict'
;
no
if
"$]"
>= 5.031009,
feature
=>
'indirect'
;
no
if
"$]"
>= 5.033001,
feature
=>
'multidimensional'
;
no
if
"$]"
>= 5.033006,
feature
=>
'bareword_filehandles'
;
use
open
':std'
,
':encoding(UTF-8)'
;
use
if
$ENV
{AUTOMATED_TESTING},
'Test::Warnings'
;
my
$yamlpp
= YAML::PP->new(
boolean
=>
'JSON::PP'
);
my
$openapi
= OpenAPI::Modern->new(
openapi_uri
=>
'/api'
,
openapi_schema
=>
$yamlpp
->load_string(OPENAPI_PREAMBLE.
<<'YAML'));
paths:
/foo:
get: {}
YAML
my
$req
= Mojo::Message::Request->new(
method
=>
'GET'
,
);
cmp_result(
$openapi
->validate_request(
$req
)->TO_JSON,
{
valid
=> true },
'request validates'
,
);
my
$frozen
= Sereal::Encoder->new({
freeze_callbacks
=> 1 })->encode(
$openapi
);
my
$thawed
= Sereal::Decoder->new->decode(
$frozen
);
cmp_result(
$thawed
->validate_request(
$req
)->TO_JSON,
{
valid
=> true },
'request can still validate'
,
);
done_testing;