Array collection format in form binding#2750
Conversation
|
@Doa86 Can you please fix issues? I really need this feature. |
|
When will there be an update? |
|
please fix the conflicts @Simon-Saaw |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2750 +/- ##
==========================================
- Coverage 98.73% 98.70% -0.03%
==========================================
Files 41 41
Lines 3080 2088 -992
==========================================
- Hits 3041 2061 -980
+ Misses 27 15 -12
Partials 12 12
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
|
Does somebody know if this functionality is now available for Gin? |
|
move the feature to next milestone v1.11 |
|
|
||
| func TestBindingFormCollectionFormat(t *testing.T) { | ||
| testFormBindingForCollectionFormat(t, "POST", | ||
| "/?slice_multi=1&slice_multi=2&slice_csv=1,2&slice_ssv=1 2&slice_pipes=1|2", "/", |
There was a problem hiding this comment.
Missing fuzzy tests here. Should try it with string type and see what happens if we feed pipes to csv param, csv to pipe param, csv to multi param etc…
| err := b.Bind(req, &obj) | ||
| assert.NoError(t, err) | ||
|
|
||
| assert.Equal(t, []int{1, 2}, obj.SliceMulti) |
There was a problem hiding this comment.
I'd refrain from using values 1 and 2 for each one of them. It can potentially conceal misbehaviour.
| } | ||
|
|
||
| func TestBindingFormCollectionFormat(t *testing.T) { | ||
| testFormBindingForCollectionFormat(t, "POST", |
There was a problem hiding this comment.
Example in README.md shows curl with GET but test only tests POST.
|
|
||
| func split(vals []string, field reflect.StructField) []string { | ||
| if cfTag := field.Tag.Get("collection_format"); cfTag != "" { | ||
| sep := "multi" |
There was a problem hiding this comment.
It will stay as sep = "multi" when invalid separator is defined e.g. collection_format:"foo"
Should it fail / warn instead silently doing fallback?
Should also add test case for it.
|
Move to #3986 |
master✔️Enables the possibility to collect array data from queries or form-data by specifying
collection_formattag in structs.