Ignore query string when extracting path parameters

Closes gh-285
This commit is contained in:
Andy Wilkinson
2016-08-19 19:51:16 +01:00
parent 9ba0a9b6be
commit a0faebdb0a
2 changed files with 18 additions and 1 deletions

View File

@@ -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()) {

View File

@@ -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);