I'm currently consuming stripe's API (available here) via OpenAPI::Client, and in some calls they have query params that are objects which are styled as deepObject (GetSubscriptionSubscriptionExposedId being one of them).
When validating those calls, i consistently get the following warning (including relevant stacktrace):
Use of uninitialized value $name in exists at /home/thisbox/.plenv/versions/5.38.0/lib/perl5/site_perl/5.38.0/OpenAPI/Client.pm line 205.
OpenAPI::Client::_param_as_array(undef, HASH(0x59648d635158)) called at /home/thisbox/.plenv/versions/5.38.0/lib/perl5/site_perl/5.38.0/OpenAPI/Client.pm line 165
OpenAPI::Client::__ANON__(undef, HASH(0x59648a8f9dc0)) called at /home/thisbox/.plenv/versions/5.38.0/lib/perl5/site_perl/5.38.0/JSON/Validator/Schema/OpenAPIv3.pm line 261
JSON::Validator::Schema::OpenAPIv3::_get_parameter_value(JSON::Validator::Schema::OpenAPIv3=HASH(0x59648a3bb318), HASH(0x59648a8f9dc0), HASH(0x59648a8bbeb8)) called at /home/thisbox/.plenv/versions/5.38.0/lib/perl5/site_perl/5.38.0/JSON/Validator/Schema/OpenAPIv2.pm line 363
JSON::Validator::Schema::OpenAPIv2::_validate_request_or_response(JSON::Validator::Schema::OpenAPIv3=HASH(0x59648a3bb318), "request", ARRAY(0x59648a86ed70), HASH(0x59648a8bbeb8)) called at /home/thisbox/.plenv/versions/5.38.0/lib/perl5/site_perl/5.38.0/JSON/Validator/Schema/OpenAPIv2.pm line 159
JSON::Validator::Schema::OpenAPIv2::validate_request(JSON::Validator::Schema::OpenAPIv3=HASH(0x59648a3bb318), ARRAY(0x59648d371570), HASH(0x59648cf251b8)) called at /home/thisbox/.plenv/versions/5.38.0/lib/perl5/site_perl/5.38.0/OpenAPI/Client.pm line 170
The suspect function is
|
sub _get_parameter_value { |
|
my ($self, $param, $get) = @_; |
|
my $schema_type = schema_type $param->{schema}; |
|
my $name = $param->{name}; |
|
$name = undef if $schema_type eq 'object' && $param->{explode} && ($param->{style} || '') =~ m!^(form|deepObject)$!; |
|
|
|
my $val = $get->{$param->{in}}->($name, $param); |
|
@$val{qw(in name)} = (@$param{qw(in name)}); |
|
return $val; |
|
} |
where on line 259 the $name is getting set undef, and that gets passed thru to the query callback, which looks like this in OpenAPI::Client
query => sub {
my ($name, $param) = @_;
my $value = _param_as_array($name => $params);
$url->query->param($name => _coerce_collection_format($value, $param));
return {exists => !!@$value, value => $value};
},
Where param_as_array optimistically expects the $name to be defined as per
sub _param_as_array {
my ($name, $params) = @_;
return !exists $params->{$name} ? [] : ref $params->{$name} eq 'ARRAY' ? $params->{$name} : [$params->{$name}];
}
I would be happy to write a patch, i'm just wondering what the reason is for setting $name to undef for deepObjects, b/c i assume there's more here than i'm seeing.
Thanks for the great modules!
I'm currently consuming stripe's API (available here) via OpenAPI::Client, and in some calls they have query params that are
objects which are styled asdeepObject(GetSubscriptionSubscriptionExposedId being one of them).When validating those calls, i consistently get the following warning (including relevant stacktrace):
The suspect function is
json-validator/lib/JSON/Validator/Schema/OpenAPIv3.pm
Lines 255 to 264 in e79c525
where on line 259 the
$nameis getting set undef, and that gets passed thru to thequerycallback, which looks like this in OpenAPI::ClientWhere
param_as_arrayoptimistically expects the$nameto be defined as perI would be happy to write a patch, i'm just wondering what the reason is for setting
$nameto undef for deepObjects, b/c i assume there's more here than i'm seeing.Thanks for the great modules!