MockMvcRequestConverter wrong stub generation for DELETE method
SergeyPirogov opened this issue · 3 comments
SergeyPirogov commented
I found an issue at MockMvcRequestConverter.
For example we have batch delete Method that uses HTTP DELETE example below:
DELETE /users?id=1&id=2&id=3
In such scenario document generator can't generate correct stub. I found the place where the problem exists. Below in convert method there is implicitly "GET" only method covered. What to do in case with DELETE?
@Override
public OperationRequest convert(MockHttpServletRequest mockRequest) {
try {
HttpHeaders headers = extractHeaders(mockRequest);
Parameters parameters = extractParameters(mockRequest);
List<OperationRequestPart> parts = extractParts(mockRequest);
Collection<RequestCookie> cookies = extractCookies(mockRequest, headers);
String queryString = mockRequest.getQueryString();
if (!StringUtils.hasText(queryString)
&& "GET".equals(mockRequest.getMethod())) {
queryString = parameters.toQueryString();
}
return new OperationRequestFactory().create(
URI.create(
getRequestUri(mockRequest) + (StringUtils.hasText(queryString)
? "?" + queryString : "")),
HttpMethod.valueOf(mockRequest.getMethod()),
FileCopyUtils.copyToByteArray(mockRequest.getInputStream()), headers,
parameters, parts, cookies);
}
catch (Exception ex) {
throw new ConversionException(ex);
}
}
mduesterhoeft commented
Thanks for the request. Would you mind to create a PR?
otrosien commented
My understanding is that this is an issue of spring-restdocs, not restdocs-wiremock, as the query params assumption in MockMvcRequestConverter
is part of spring-restdocs-mockmvc code [1], and as such we would have to open an issue upstream.
SergeyPirogov commented
@otrosien I think yes