-
-
Notifications
You must be signed in to change notification settings - Fork 482
Description
When I'm trying to validate an openapi v3 yaml file with "parameters:" section under the path (with a single parameter)
and "parameters:" section under the operation (method) that should override the "global" parameter I'm getting this error:
"operation %s %s must define exactly all path parameters".
The bug is in "func (paths Paths) Validate(c context.Context)" at paths.go
The error is because code counts how many path parameters there is in the path (i.e. "pathParamsCount"),
the global parameters at the path level (i.e. "globalCount")
and the local parameters at the operation level (i.e. "count"),
but the comparison between those counters is wrong:
if count+globalCount != pathParamsCount {
return fmt.Errorf("operation %s %s must define exactly all path parameters", method, path)
}
in the attached example you can see that I have:
1 path parameter (customer_id) - "pathParamsCount" = 1
1 global parameter - "globalCount" = 1
1 local parameter (that should override the global definition) - "count" = 1
therefore, the right comparison should be:
if count+globalCount < pathParamsCount {
return fmt.Errorf("operation %s %s must define exactly all path parameters", method, path)
}