Description
Explanation
When a path contains several variables with "{}" characters, the template computed for this URL is incorrect.
Example with URL template computed correctly :
- path :
/avis/by_id_utilisateur-{id_utilisateur}
- template computed :
/avis/by_id_utilisateur-{}
Example with URL template incorrect :
- path :
/avis/by_id_utilisateur-{id_utilisateur}_code_support-{code_support}
- template computed :
/avis/by_id_utilisateur-{}
If we have an API with these two paths, /avis/by_id_utilisateur-{id_utilisateur}
and /avis/by_id_utilisateur-{id_utilisateur}_code_support-{code_support}
thus de verification will fail with an error Two path items have the same signature: /avis/by_id_utilisateur-{}
.
This is because of wrong templates computed during the control process.
Analysis / Solution
After, an analysis of code, this template URL computation was made by a method that does a replace from a regex pattern.
...
public class PathsDiff {
private static final String REGEX_PATH = "\\{([^/]+)}";
...
private static String normalizePath(String path) {
return path.replaceAll(REGEX_PATH, "{}");
}
...
}
This pattern is wrong, we should have "\{([^/{}]+)}" to exclude "{" and "}" from detection.
I tested this pattern locally and it's ok for me with this last regex pattern.
If you want I can correct it. I will create a PR if nobody does it before me :p
thanks.
David.