diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/request/PathParametersSnippet.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/request/PathParametersSnippet.java index 42178a426..9a40b4629 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/request/PathParametersSnippet.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/request/PathParametersSnippet.java @@ -120,7 +120,8 @@ private String extractUrlTemplate(Operation operation) { private static String getParameterName(String match) { int colonIndex = match.indexOf(':'); - return (colonIndex != -1) ? match.substring(0, colonIndex) : match; + String name = (colonIndex != -1) ? match.substring(0, colonIndex) : match; + return name.startsWith("*") ? name.substring(1) : name; } @Override diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/PathParametersSnippetTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/PathParametersSnippetTests.java index 131468f4b..d2c6ef404 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/PathParametersSnippetTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/PathParametersSnippetTests.java @@ -170,6 +170,19 @@ void additionalDescriptorsWithRelaxedRequestParameters(OperationBuilder operatio .row("`b`", "two")); } + @RenderedSnippetTest + void pathParametersWithCaptureVariable(OperationBuilder operationBuilder, AssertableSnippets snippets, + TemplateFormat templateFormat) throws IOException { + new PathParametersSnippet( + Arrays.asList(parameterWithName("a").description("one"), parameterWithName("b").description("two"))) + .document(operationBuilder.attribute(RestDocumentationGenerator.ATTRIBUTE_NAME_URL_TEMPLATE, "/{a}/{*b}") + .build()); + assertThat(snippets.pathParameters()).isTable( + (table) -> table.withTitleAndHeader(getTitle(templateFormat, "/{a}/{*b}"), "Parameter", "Description") + .row("`a`", "one") + .row("`b`", "two")); + } + @RenderedSnippetTest void pathParametersWithEscapedContent(OperationBuilder operationBuilder, AssertableSnippets snippets, TemplateFormat templateFormat) throws IOException {