Commit d722c05
committed
[dart-dio] Fix
The `json_serializable` dart-dio serialize template only handled
`{{#bodyParam}}`, which meant operations using
`application/x-www-form-urlencoded` or `multipart/form-data` produced an
empty `try {}` block and a `_bodyData` that was never assigned. The
request body was silently dropped.
This mirrors the handling already present in the `built_value` template
for the same generator, but without `built_value`-specific
`encodeFormParameter` / `_serializers` calls since `json_serializable`
passes values directly (consistent with its `query_param.mustache`).
- `application/x-www-form-urlencoded` -> `Map<String, dynamic>`
- `multipart/form-data` -> `FormData.fromMap(<String, dynamic>{...})`
- Optional / non-required + non-nullable params are conditionally
included with `if (paramName != null)`.
- The existing `bodyParam` branch is preserved, just properly indented
(to match `built_value`).json_serializable serialize template to support hasFormParams
1 parent 20e3283 commit d722c05
1 file changed
Lines changed: 19 additions & 1 deletion
File tree
- modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/json_serializable/api
Lines changed: 19 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
0 commit comments