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
fix: router now support colon sign #552
Conversation
Codecov Report
@@ Coverage Diff @@
## master #552 +/- ##
=======================================
Coverage 87.24% 87.24%
=======================================
Files 7 7
Lines 1560 1560
=======================================
Hits 1361 1361
Misses 117 117
Partials 82 82
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regexp should not allow invalid paths.
Please fix regexp and add additional tests to cover my example.
operation.go
Outdated
@@ -437,7 +437,7 @@ func parseMimeTypeList(mimeTypeList string, typeList *[]string, format string) e | |||
return nil | |||
} | |||
|
|||
var routerPattern = regexp.MustCompile(`([\w\.\/\-{}\+]+)[^\[]+\[([^\]]+)`) | |||
var routerPattern = regexp.MustCompile(`([\w\.\/\-{}\+:]+)[^\[]+\[([^\]]+)`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix the regexp accordigly
The following routes should not be valid
"/@router :customer/get-wishlist/{wishlist_id}:move [post]"
path format
In addition, a URI reference (Section 4.1) may be a relative-path reference, in which case the first path segment cannot contain a colon (":") character.
Original regex: Well, I've come up with 4 different solutions, all of them pass the tests (explanation are just after):
Now the explanations:
I'll update my MR with the second solution as I do think it is the best one. I'll update the MR if you think another solution is better. |
381b917
to
70f6318
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Useful for custom methods using custom verbs
Describe the PR
Add colon sign support for router parse method.
Relation issue
#551
Additional context
Custom methods as described in the Google API design documentation (https://cloud.google.com/apis/design/custom_methods) does not work ATM. ex:
/objects:move [post]
Unit test are passing. Fix works well on my side.
Do you want me to change the commit type from "fix" to "feat"?
Is the unit test enough?
Have a good day!