-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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: split extensions param respecting open/close brackets #1107
Conversation
It this PR related to any open issue? |
No. I needed to use extensions params and had problems with texts containing comma and then opened this PR. |
@ubogdan could you please approve running the workflows? |
It seems I missed this notification. |
Codecov Report
@@ Coverage Diff @@
## master #1107 +/- ##
==========================================
+ Coverage 94.59% 94.73% +0.13%
==========================================
Files 9 10 +1
Lines 2370 2433 +63
==========================================
+ Hits 2242 2305 +63
Misses 67 67
Partials 61 61
Continue to review full report at Codecov.
|
field_parser.go
Outdated
@@ -207,7 +207,9 @@ func (ps *tagBaseFieldParser) ComplementSchema(schema *spec.Schema) error { | |||
extensionsTag := ps.tag.Get(extensionsTag) | |||
if extensionsTag != "" { | |||
structField.extensions = map[string]interface{}{} | |||
extensionsTag := strings.ReplaceAll(extensionsTag, `,,`, `{{escape-comma}}`) | |||
for _, val := range strings.Split(extensionsTag, ",") { |
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.
Adding double-quoted is an ugly hack.
The solution is to line instead of split by comma by respection open/close brackets.
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.
I agree. double-comma was a quick fix. I'll try the solution you suggested
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.
Changed as suggested
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
@helder-jaspion Thanks for your contribution! |
Describe the PR
split extensions param respecting open/close brackets
// @Param range query string true "Range" default([0, 9]) extensions(x-example=[0,9])
Relation issue
None.
Additional context
When using extensions param with text containing comma the extensions were getting splited wrong.