if ($::DEBUG or $::TESTING) { ...
my $ua = Mojo::UserAgent
->with_roles('something...')
->new(
...,
openapi_document => ...,
validate_requests => 1,
validate_responses => 0,
on_request_validation => sub ($request, $result) {
# log request
if (not $request) {
# request failed... fail a test or something...
}
},
);
$self->ua($ua);
}
$ua->get('/foo/bar');
# and then in your .t file:
$TESTING = 1;
$ua->app($my_test_server);
# run tests... connections go through the test app and requests are validated.