Ignore query string when extracting path parameters
Closes gh-285
This commit is contained in:
@@ -116,7 +116,7 @@ public class PathParametersSnippet extends AbstractParametersSnippet {
|
||||
|
||||
@Override
|
||||
protected Set<String> extractActualParameters(Operation operation) {
|
||||
String urlTemplate = extractUrlTemplate(operation);
|
||||
String urlTemplate = removeQueryStringIfPresent(extractUrlTemplate(operation));
|
||||
Matcher matcher = NAMES_PATTERN.matcher(urlTemplate);
|
||||
Set<String> actualParameters = new HashSet<>();
|
||||
while (matcher.find()) {
|
||||
|
||||
@@ -130,6 +130,23 @@ public class PathParametersSnippetTests extends AbstractSnippetTests {
|
||||
"/{a}/{b}?foo=bar").build());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pathParametersWithQueryStringWithParameters() throws IOException {
|
||||
this.snippet
|
||||
.expectPathParameters("path-parameters-with-query-string-with-parameters")
|
||||
.withContents(
|
||||
tableWithTitleAndHeader(getTitle(), "Parameter", "Description")
|
||||
.row("`a`", "one").row("`b`", "two"));
|
||||
new PathParametersSnippet(Arrays.asList(parameterWithName("a").description("one"),
|
||||
parameterWithName("b").description("two")))
|
||||
.document(operationBuilder(
|
||||
"path-parameters-with-query-string-with-parameters")
|
||||
.attribute(
|
||||
RestDocumentationGenerator.ATTRIBUTE_NAME_URL_TEMPLATE,
|
||||
"/{a}/{b}?foo={c}")
|
||||
.build());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pathParametersWithCustomAttributes() throws IOException {
|
||||
TemplateResourceResolver resolver = mock(TemplateResourceResolver.class);
|
||||
|
||||
Reference in New Issue
Block a user