- edited description
Request validation for Multi-segment path parameters in Swagger 2.0
This issue is related to the below proposal and PR which has already been merged. https://bitbucket.org/atlassian/swagger-request-validator/issues/121/multi-segment-path-parameters-in-swagger
When i was trying to use the version 1.4.7 for request validation then i found that we need to do some further enhancement to achieve our purpose.
When we call the method validateRequest(@Nonnull final Request request) of the class SwaggerRequestResponseValidator then it fails to do the request validation in case of Multi-segment path parameters.
Below is my proposal to fix this problem:
Implement another overload function of validateRequest(@Nonnull final Request request, boleean hasDynamicRequestURI) where hasDynamicRequestURI flag indicate that whether we are going to do the request validation for Multi-segment path parameters.
@Nonnull
public ValidationReport validateRequest(@Nonnull final Request request) {
validateRequest(request, false)
}
@Nonnull
public ValidationReport validateRequest(@Nonnull final Request request, boolean hasDynamicRequestURI) {
requireNonNull(request, "A request is required");
return validateOnApiOperation(
request.getPath(),
request.getMethod(),
apiOperation -> requestValidator.validateRequest(request, apiOperation),
(apiOperation, report) -> withWhitelistApplied(report, apiOperation, request, null), hasDynamicRequestURI);
}
Then change the below logic in validateOnApiOperation method of SwaggerRequestResponseValidator class
private ValidationReport validateOnApiOperation(@Nonnull final String path,
@Nonnull final Request.Method method,
@Nonnull final Function<ApiOperation, ValidationReport> validationFunction,
@Nonnull final BiFunction<ApiOperation, ValidationReport, ValidationReport> whitelistingFunction, boolean hasDynamicRequestURI) {
final ValidationReport.MessageContext context = ValidationReport.MessageContext.create()
.withRequestPath(path)
.withRequestMethod(method)
.build();
ApiOperationMatch apiOperationMatch
If(hasDynamicRequestURI){
apiOperationMatch = apiOperationResolver.findApiOperation(path, method, ApiPath::matchesDynamicPath);
} else {
apiOperationMatch = apiOperationResolver.findApiOperation(path, method);
}
Please provide your feedback on this. If you would be okay with this proposed change then i would create PR for the same.
Comments (5)
-
reporter -
If it helps with the context this is a follow on from my issue 121 (https://bitbucket.org/atlassian/swagger-request-validator/issues/121/multi-segment-path-parameters-in-swagger)
We found out there was a bit more we needed to do to get this to work completely for us.
-
reporter @James Navin : I am not sure why the PR has been declined. Still i am looking to have this fix and would be happy to discuss more on the same.
I am not getting the option to reopen the declined PR.
Could you please help me to reopen the below PR?
https://bitbucket.org/atlassian/swagger-request-validator/pull-requests/115/issue-169/diff
-
Hi Chandan,
The PR was closed due to lack of activity. Bitbucket doesn’t allow PRs to be re-opened, but you are more than welcome to raise a new PR.
Looking back at the comments on that PR it seems one of the major points was around targeting against v1 vs v2. I am no longer accepting PRs against the v1 branch. Please ensure that your PR targets the current master so that it can be included in the v2 release train. If there are changes you depend on that are not present in v2 please feel free to either include them in your PR or to raise a separate PR with those changes.
Thanks,
James
-
- changed status to resolved
Marking as resolved due to inactivity. Please feel free to re-open if you still wish to pursue it.
- Log in to comment