-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
/spring-rest2ts-spring : RequestMapping path variable definition syntax is not supported #49
Comments
A temporary resolution proposed at #50 while awaiting resolution on spring-projects/spring-framework#32093 |
Hi |
Unfortunately spring-projects/spring-framework#32093 did not go as I had hoped and it appears as though the SpringFramework developer(s) are leaving users with little choice but to duplicate parsing functionality. It also appears that there is one other thing to consider than I have implemented at #50 which you may view at https://docs.spring.io/spring-framework/docs/6.1.3/javadoc-api/org/springframework/web/util/pattern/PathPattern.html and that is the * character typed as {*variable} which ends up with multiple path segments named as one. |
I had a look on this and for me this should be an easy fix but I could be wrong. My view is following: In https://docs.spring.io/spring-framework/docs/3.2.16.RELEASE/spring-framework-reference/html/mvc.html ` The @RequestMapping annotation supports the use of regular expressions in URI template variables. The syntax is {varName:regex} where the first part defines the variable name and the second - the regular expression.For example: @RequestMapping("/spring-web/{symbolicName:[a-z-]+}-{version:\d\.\d\.\d}{extension:\.[a-z]+}") ` |
Yes. To clarify, my hope was to use Spring to parse it and then check for PathElement instance to find out how to deal with it. There is one additional caveat not supported by spring-rest2ts and that is for any expression defined like, /test/{*multiple} with an assigning @PathVariable of let's say (long multiple) where /test/1/2/3/4 is given, (long multiple) is not forced to be an array but is consumed in multiple chunks of path segments. My PR only deals with the regex case, however {*multiple} should also be handled. I will go ahead and come up with a solution for the {*multiple} case as well and commit it into the PR in the next few hours. |
Have you considered using something like https://github.com/mozilla/rhino ? Or was the partial implementation on TypeScript for other purposes? Frankly for what I'm trying to do this project works. I'm solely using it to generate Axios APIs from a maven plugin I wrote for my Spring controllers and having 0 dependencies to worry about really helps. |
I've gone ahead and rebased #50 with the mentioned changes which now covers "capture the rest" pattern. Hopefully that helps. |
It appears that the regex support for path variable pattern definition is currently not supported. Having a controller with the following mapping, "/{id:^[0-9]*$}" results in an unchecked exception incorrectly stating that the variable cannot be found.
The text was updated successfully, but these errors were encountered: