From 2a358c7eb0c81d3a0cd96ce05de311f6bc2b6727 Mon Sep 17 00:00:00 2001 From: Francisco Javier Tirado Sarti <65240126+fjtirado@users.noreply.github.com> Date: Wed, 8 Nov 2023 11:43:42 +0100 Subject: [PATCH] Merge pull request #556 from gabriel-farache/fix_urlpattermatcher Fix UrlPatternMatcher not matching parameters in path containing "-" character --- .../openapi/generator/providers/UrlPatternMatcher.java | 2 +- .../openapi/generator/providers/UrlPatternMatcherTest.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/runtime/src/main/java/io/quarkiverse/openapi/generator/providers/UrlPatternMatcher.java b/runtime/src/main/java/io/quarkiverse/openapi/generator/providers/UrlPatternMatcher.java index 1753bb92..819a85a6 100644 --- a/runtime/src/main/java/io/quarkiverse/openapi/generator/providers/UrlPatternMatcher.java +++ b/runtime/src/main/java/io/quarkiverse/openapi/generator/providers/UrlPatternMatcher.java @@ -64,7 +64,7 @@ */ public class UrlPatternMatcher { // Finds parameters in the URL pattern string. - private static final String URL_PARAM_REGEX = "\\{(\\w*?)\\}"; + private static final String URL_PARAM_REGEX = "\\{(\\S*?)\\}"; // Replaces parameter names in the URL pattern string to match parameters in URLs. private static final String URL_PARAM_MATCH_REGEX = "\\([%\\\\w-.\\\\~!\\$&'\\\\(\\\\)\\\\*\\\\+,;=:\\\\[\\\\]@]+?\\)"; diff --git a/runtime/src/test/java/io/quarkiverse/openapi/generator/providers/UrlPatternMatcherTest.java b/runtime/src/test/java/io/quarkiverse/openapi/generator/providers/UrlPatternMatcherTest.java index 352bc488..9610f7bf 100644 --- a/runtime/src/test/java/io/quarkiverse/openapi/generator/providers/UrlPatternMatcherTest.java +++ b/runtime/src/test/java/io/quarkiverse/openapi/generator/providers/UrlPatternMatcherTest.java @@ -31,7 +31,8 @@ private static Stream providePathsThatMatch() { Arguments.of("/{id}/pets/{id2}", "/1/pets/2?q=1&q2=2"), Arguments.of("/{id}/{foo}/{id2}", "/1/2/3?q=1&q2=2"), Arguments.of("/{id}/{foo}/{id2}", "/1/2/3"), - Arguments.of("/v2/pets/{id}", "/v2/pets/1")); + Arguments.of("/v2/pets/{id}", "/v2/pets/1"), + Arguments.of("/pets/{pet-id}/types/{type-id}", "/pets/1/types/2")); } } \ No newline at end of file