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
Commit d6f2a37
Browse filesBrowse the repository at this point in the historyBrowse files
feat(form-data): handle unmarshalling and validation of non-file JSON form data fields (#1060)
* feat(form-data): handle unmarshalling and validation of non-file JSON form data fields
* fix(form-data): harden JSON multipart field handling
- Emit the tagged content type in the generated OpenAPI encoding instead
of always text/plain, so the spec matches how the field is parsed.
- Precompute the field schema and defaults at registration time rather
than on every request, avoiding a per-request reflection walk.
- Panic at registration with actionable guidance when a struct/map form
field lacks contentType:"application/json", instead of a confusing
request-time "unsupported param type" error.
- Resolve the content type via parseContentType so +json suffixes and
;charset parameters are handled consistently with the body codecs.
- Share default application with the request body path (setDefaults) and
add a benchmark.
---------
Co-authored-by: Robert Thomas <[email protected]>
The files are decoded according to the specified contentType. If no contentType is provided, it defaults to `application/octet-stream`.
215
218
219
+
Non-file fields in multipart form data can be unmarshalled from JSON and validated, by setting their content-type to `application/json`. Field content in the request must be valid JSON.
220
+
221
+
216
222
## Request Example
217
223
218
224
Here is an example request input struct, which has a path param, query param, header param, and a structured body alongside the raw body bytes:
0 commit comments