Commit 209f7d1
authored
* [dart-dio] Fix `json_serializable` serialize template to support `hasFormParams`
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`).
* [dart-dio] Update samples after `json_serializable` form-param fix
Regenerates the `petstore_client_lib_fake-json_serializable` sample via
`./bin/generate-samples.sh bin/configs/dart-dio*` to reflect the updated
`serialize.mustache` template. Previously empty `try {}` blocks in
operations using `application/x-www-form-urlencoded` or
`multipart/form-data` (e.g. `updatePetWithForm`, `uploadFile`,
`testEndpointParameters`, `testEnumParameters`, `testQueryParameterCollectionFormat`)
now correctly populate `_bodyData`. Existing body-param operations are
regenerated with consistent indentation.
1 parent ba91cc6 commit 209f7d1
7 files changed
Lines changed: 103 additions & 25 deletions
File tree
- modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/json_serializable/api
- samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/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 | + | |
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
| 60 | + | |
| 61 | + | |
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
| |||
Lines changed: 54 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
293 | 293 | | |
294 | 294 | | |
295 | 295 | | |
296 | | - | |
| 296 | + | |
| 297 | + | |
297 | 298 | | |
298 | 299 | | |
299 | 300 | | |
| |||
360 | 361 | | |
361 | 362 | | |
362 | 363 | | |
363 | | - | |
| 364 | + | |
| 365 | + | |
364 | 366 | | |
365 | 367 | | |
366 | 368 | | |
| |||
450 | 452 | | |
451 | 453 | | |
452 | 454 | | |
453 | | - | |
| 455 | + | |
| 456 | + | |
454 | 457 | | |
455 | 458 | | |
456 | 459 | | |
| |||
540 | 543 | | |
541 | 544 | | |
542 | 545 | | |
543 | | - | |
| 546 | + | |
| 547 | + | |
544 | 548 | | |
545 | 549 | | |
546 | 550 | | |
| |||
630 | 634 | | |
631 | 635 | | |
632 | 636 | | |
633 | | - | |
| 637 | + | |
| 638 | + | |
634 | 639 | | |
635 | 640 | | |
636 | 641 | | |
| |||
720 | 725 | | |
721 | 726 | | |
722 | 727 | | |
723 | | - | |
| 728 | + | |
| 729 | + | |
724 | 730 | | |
725 | 731 | | |
726 | 732 | | |
| |||
810 | 816 | | |
811 | 817 | | |
812 | 818 | | |
813 | | - | |
| 819 | + | |
| 820 | + | |
814 | 821 | | |
815 | 822 | | |
816 | 823 | | |
| |||
875 | 882 | | |
876 | 883 | | |
877 | 884 | | |
878 | | - | |
| 885 | + | |
| 886 | + | |
879 | 887 | | |
880 | 888 | | |
881 | 889 | | |
| |||
940 | 948 | | |
941 | 949 | | |
942 | 950 | | |
943 | | - | |
| 951 | + | |
| 952 | + | |
944 | 953 | | |
945 | 954 | | |
946 | 955 | | |
| |||
1011 | 1020 | | |
1012 | 1021 | | |
1013 | 1022 | | |
1014 | | - | |
| 1023 | + | |
| 1024 | + | |
1015 | 1025 | | |
1016 | 1026 | | |
1017 | 1027 | | |
| |||
1078 | 1088 | | |
1079 | 1089 | | |
1080 | 1090 | | |
1081 | | - | |
| 1091 | + | |
| 1092 | + | |
1082 | 1093 | | |
1083 | 1094 | | |
1084 | 1095 | | |
| |||
1200 | 1211 | | |
1201 | 1212 | | |
1202 | 1213 | | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
1203 | 1230 | | |
1204 | 1231 | | |
1205 | 1232 | | |
| |||
1291 | 1318 | | |
1292 | 1319 | | |
1293 | 1320 | | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
1294 | 1325 | | |
1295 | 1326 | | |
1296 | 1327 | | |
| |||
1431 | 1462 | | |
1432 | 1463 | | |
1433 | 1464 | | |
1434 | | - | |
| 1465 | + | |
| 1466 | + | |
1435 | 1467 | | |
1436 | 1468 | | |
1437 | 1469 | | |
| |||
1496 | 1528 | | |
1497 | 1529 | | |
1498 | 1530 | | |
1499 | | - | |
| 1531 | + | |
| 1532 | + | |
1500 | 1533 | | |
1501 | 1534 | | |
1502 | 1535 | | |
| |||
1563 | 1596 | | |
1564 | 1597 | | |
1565 | 1598 | | |
| 1599 | + | |
| 1600 | + | |
| 1601 | + | |
| 1602 | + | |
1566 | 1603 | | |
1567 | 1604 | | |
1568 | 1605 | | |
| |||
1628 | 1665 | | |
1629 | 1666 | | |
1630 | 1667 | | |
1631 | | - | |
| 1668 | + | |
| 1669 | + | |
1632 | 1670 | | |
1633 | 1671 | | |
1634 | 1672 | | |
| |||
1763 | 1801 | | |
1764 | 1802 | | |
1765 | 1803 | | |
1766 | | - | |
| 1804 | + | |
| 1805 | + | |
1767 | 1806 | | |
1768 | 1807 | | |
1769 | 1808 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
| 67 | + | |
| 68 | + | |
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
| |||
Lines changed: 16 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
| 66 | + | |
| 67 | + | |
67 | 68 | | |
68 | 69 | | |
69 | 70 | | |
| |||
432 | 433 | | |
433 | 434 | | |
434 | 435 | | |
435 | | - | |
| 436 | + | |
| 437 | + | |
436 | 438 | | |
437 | 439 | | |
438 | 440 | | |
| |||
506 | 508 | | |
507 | 509 | | |
508 | 510 | | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
509 | 515 | | |
510 | 516 | | |
511 | 517 | | |
| |||
580 | 586 | | |
581 | 587 | | |
582 | 588 | | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
583 | 593 | | |
584 | 594 | | |
585 | 595 | | |
| |||
679 | 689 | | |
680 | 690 | | |
681 | 691 | | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
682 | 696 | | |
683 | 697 | | |
684 | 698 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
253 | 253 | | |
254 | 254 | | |
255 | 255 | | |
256 | | - | |
| 256 | + | |
| 257 | + | |
257 | 258 | | |
258 | 259 | | |
259 | 260 | | |
| |||
Lines changed: 8 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
| 60 | + | |
| 61 | + | |
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
| |||
122 | 123 | | |
123 | 124 | | |
124 | 125 | | |
125 | | - | |
| 126 | + | |
| 127 | + | |
126 | 128 | | |
127 | 129 | | |
128 | 130 | | |
| |||
187 | 189 | | |
188 | 190 | | |
189 | 191 | | |
190 | | - | |
| 192 | + | |
| 193 | + | |
191 | 194 | | |
192 | 195 | | |
193 | 196 | | |
| |||
498 | 501 | | |
499 | 502 | | |
500 | 503 | | |
501 | | - | |
| 504 | + | |
| 505 | + | |
502 | 506 | | |
503 | 507 | | |
504 | 508 | | |
| |||
0 commit comments