You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
MarshalForm ignores the style and explode of a property's encoding #186
MarshalForm takes a map[string]RequestBodyEncoding, but only reads ContentType from it. Style and Explode are ignored, so an array property is always written with indexed keys:
Per the OpenAPI Encoding Object, style: form, explode: true serializes as repeated keys: topic=news&topic=releases. A server which reads repeated keys sees no topic at all. BindForm accepts repeated keys, name[] and name[i], so the mismatch only shows up against servers that aren't generated by oapi-codegen.
Expected
When a property's encoding sets Style or Explode, MarshalForm serializes it the way a query parameter of that style would be:
style
explode
array ["a", "b"]
form
true (default)
topic=a&topic=b
form
false
topic=a,b
spaceDelimited
false (default)
topic=a b
pipeDelimited
false (default)
topic=a|b
deepObject
topic[0]=a&topic[1]=b (today's output)
A property with no encoding, or with an encoding that sets neither field, keeps today's bracketed output, so nothing changes for existing callers: generated code passes nil today.
Related: the ContentType branch always fails
While here: the application/json branch of MarshalForm returns unsupported encoding, only application/json is supported even when the content type isapplication/json, because the error return isn't in an else. It also marshals the reflect.Value rather than the value it holds. That needs fixing before the generator can pass encodings through, or any spec with a JSON-encoded form property would start failing.
Activity
fix: honour style and explode in MarshalForm encodings (oapi-codegen#187