quarkiverse / quarkus-openapi-generator

OpenAPI Generator - REST Client Generator
Apache License 2.0
108 stars 69 forks source link

Fix UrlPatternMatcher not matching parameters in path containing "-" character #556

Closed gabriel-farache closed 8 months ago

gabriel-farache commented 8 months ago

Fixes: #555

The UrlPatternMatcher is not matching URLs with path parameters containing the "-" character. The following error is throw when using such URL:

java.util.regex.PatternSyntaxException: Illegal repetition near index 7
/pets/{pet-id}/types/{type-id}(?:\?.*?)?$

The root cause is the following pattern: private static final String URL_PARAM_REGEX = "\\{(\\w*?)\\}";. Here the \w is not considering the "-" character as part of a word thus not matching.

The "-" being an authorized character in the URL parameter, the pattern used shall match.

By using \S instead, the pattern is matching the parameters as expected.


Please make sure that your PR meets the following requirements:

How to backport a pull request to a different branch? In order to automatically create a **backporting pull request** please add one or more labels having the following format `backport-`, where `` is the name of the branch where the pull request must be backported to (e.g., `backport-quarkus2` to backport the original PR to the `quarkus2` branch). > **NOTE**: **backporting** is an action aiming to move a change (usually a commit) from a branch (usually the main one) to another one, which is generally referring to a still maintained release branch. Keeping it simple: it is about to move a specific change or a set of them from one branch to another. Once the original pull request is successfully merged, the automated action will create one backporting pull request per each label (with the previous format) that has been added. If something goes wrong, the author will be notified and at this point a manual backporting is needed. > **NOTE**: this automated backporting is triggered whenever a pull request on `main` branch is labeled or closed, but both conditions must be satisfied to get the new PR created.
github-actions[bot] commented 8 months ago

🎊 PR Preview 0a75a3bbfe613e01708ae7ed215a472452f751f4 has been successfully built and deployed. See the documentation preview here.

hbelmiro commented 8 months ago

@allcontributors please add @gabriel-farache for code and test

allcontributors[bot] commented 8 months ago

@hbelmiro

I've put up a pull request to add @gabriel-farache! :tada: