Commit b30537d
fix(angular): place body before accept in multi-content overload signatures (#3354)
* fix(angular): place body before accept in multi-content overload signatures
For operations with a request body, path parameters, and multiple response
content types, the generated overloads incorrectly placed the `accept` literal
parameter before the body. This broke TypeScript callers (API break) and could
throw at runtime when a body object was passed into the `accept` position and
reached `accept.includes(...)`.
Split props into three ordered buckets — required non-body, body, optional
non-body — so all generated signatures follow the natural call shape:
`method(pathParams, body, accept, optionalParams, options)`
Optional body params in per-content-type overloads are rendered as positionally
required (`name: Type | undefined`) to satisfy TS1016, which forbids required
params after optional ones.
Closes #3349
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* test(angular): add regression tests and samples for body param order fix
- Extend `angular-multi-content-query-params` spec with a `confirmReservation`
POST endpoint (optional body + multi-content) and update its snapshots to
assert body-before-accept order in all generated overloads
- Add `updatePetById` (PUT, required body) and `patchPetById` (PATCH, optional
body) to the Angular sample petstore spec, both with multi-content responses,
to cover both required and optional body variants end-to-end
- Regenerate all affected Angular sample outputs (http-client, http-both,
http-resource, endpoints-zod, http-resource-zod) from the updated spec
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* test(angular): cover required body before accept in multi-content overloads
Complements the optional-body regression test for #3349: verifies that a
required body param also appears before `accept` in all generated overload
signatures and is not widened to `Type | undefined` (the TS1016 transform
only fires for optional props).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* refactor(angular): anchor optional-marker stripping to body param identifier
Replace brittle p.definition.replace('?:', ':') with an identifier-anchored
slice using `${p.name}?:` as the prefix. This guarantees we only strip the
parameter's own optional marker, never a '?:' that may appear elsewhere in
the type (e.g. mapped or conditional types).
Also refresh angular-app snapshot fixtures for the new updatePetById /
patchPetById endpoints introduced in this PR.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* refactor(angular): extract partitionPropsForMultiContent helper
Replace three duplicated filter-by-(required/body) blocks in
generateHttpClientImplementation with a single partitionPropsForMultiContent
helper. Both the type-level overload and the implementation site now share
the same partitioning logic, eliminating drift risk between the two and
addressing PR #3354 review comments 2, 3, and 4.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* test(angular): assert TS1016-safe optional-body form in overloads
The existing regression test only verified ordering of body vs accept
via indexOf. Add a positive assertion that the per-content-type overloads
render `confirmReservationBody: ... | undefined` (positionally required,
type widened) immediately followed by a required `accept` literal, plus
a negative assertion that no `confirmReservationBody?:` is followed by
a required `accept` literal anywhere — which would re-introduce TS1016
(required parameter cannot follow optional).
Addresses PR #3354 review comment 5.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix(samples): add missing UpdatePetByIdAccept and PatchPetByIdAccept exports
The http-resource and http-resource-zod sample variants referenced
UpdatePetByIdAccept and PatchPetByIdAccept in their updatePetById and
patchPetById signatures but were missing the corresponding type/const
definitions, causing TS compilation errors.
Added the type unions and const objects after ShowPetByIdAccept in:
- src/api/http-resource/pets/pets.service.ts
- src/api/http-resource-zod/pets/pets.service.ts
- __snapshots__/api/http-resource/pets/pets.service.ts
- __snapshots__/api/http-resource-zod/pets/pets.service.ts
* test(angular): add /confirm suffix to confirmReservation route fixtures
Route strings in the regression test now match the OpenAPI fixture path
'/reservations/{token}/confirm', making the test self-consistent.
* fix(angular): treat falsy defaults as present in prop partitioning
Use a nullish check (== null) instead of a truthiness check when deciding
whether a required non-body prop has no default value.
* fix(angular): tighten undefined detection in overload body typing
Replace required.includes('undefined') with a word-boundary regex check
to avoid brittle substring matches while preserving behavior.
* fix(angular): unblock multi-content ci
Restore the original required-parameter partition check in the
Angular HttpClient generator so the multi-content refactor no
longer trips unicorn/no-null.
Emit Accept helper types for httpResource mutation methods as
well. This keeps mixed resource/service outputs consistent with
the generated mutation overloads and fixes the Angular sample
snapshot regression that appears once lint passes.
Refs #3354
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: The Ult <ult_dev@pm.me>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent ee5933c commit b30537d
45 files changed
Lines changed: 4361 additions & 17 deletions
File tree
- packages/angular/src
- samples/angular-app
- __snapshots__/api
- endpoints-zod
- model
- pets
- http-both/pets
- http-client-custom-params/pets
- http-client/pets
- http-resource-zod
- model
- pets
- http-resource/pets
- src/api
- endpoints-zod
- model
- pets
- http-both/pets
- http-client-custom-params/pets
- http-client/pets
- http-resource-zod
- model
- pets
- http-resource/pets
- tests
- __snapshots__/angular/multi-content-query-params
- model
- specifications
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
817 | 817 | | |
818 | 818 | | |
819 | 819 | | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
820 | 973 | | |
821 | 974 | | |
822 | 975 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
| |||
66 | 68 | | |
67 | 69 | | |
68 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
69 | 101 | | |
70 | 102 | | |
71 | 103 | | |
| |||
565 | 597 | | |
566 | 598 | | |
567 | 599 | | |
568 | | - | |
569 | | - | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
570 | 606 | | |
571 | 607 | | |
572 | | - | |
573 | | - | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
574 | 628 | | |
575 | 629 | | |
576 | 630 | | |
577 | 631 | | |
578 | 632 | | |
579 | 633 | | |
580 | 634 | | |
581 | | - | |
| 635 | + | |
| 636 | + | |
582 | 637 | | |
583 | | - | |
| 638 | + | |
584 | 639 | | |
585 | 640 | | |
586 | 641 | | |
| |||
589 | 644 | | |
590 | 645 | | |
591 | 646 | | |
592 | | - | |
| 647 | + | |
| 648 | + | |
593 | 649 | | |
594 | | - | |
| 650 | + | |
595 | 651 | | |
596 | 652 | | |
597 | 653 | | |
| |||
630 | 686 | | |
631 | 687 | | |
632 | 688 | | |
633 | | - | |
634 | | - | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
635 | 698 | | |
636 | 699 | | |
637 | | - | |
638 | | - | |
| 700 | + | |
639 | 701 | | |
640 | 702 | | |
641 | 703 | | |
642 | | - | |
| 704 | + | |
| 705 | + | |
643 | 706 | | |
644 | | - | |
| 707 | + | |
645 | 708 | | |
646 | 709 | | |
647 | 710 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
646 | 646 | | |
647 | 647 | | |
648 | 648 | | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
649 | 729 | | |
650 | 730 | | |
651 | 731 | | |
| |||
0 commit comments