Commit db9049c
authored
Fix generated client transport shape (#137)
* fix generated client transport shape
* test(runtime): align Pydantic serialization tests with new transport shape
PR #137 unifies request body construction through the new ClientRequest
DTO: bodies are JSON-encoded to bytes once and passed to httpx as
`content=<bytes>` regardless of whether the input was a Pydantic model
or a plain dict. The two json_data tests in test_pydantic_serialization
were still asserting the old `json={...}` kwarg shape, so they failed
in CI.
Update both tests (sync + async) to verify the new contract:
- `json` kwarg is never present
- `content` round-trips back to the expected dict via json.loads
- Content-Type: application/json is set on the request headers
* address review feedback: simpler transport DTOs
Per @avkonst's review on PR #137, plus a couple of related cleanups:
- Drop the `Client` prefix from transport DTO names across all three
languages: `Client{Request,Headers,Response}` -> `{Request,Headers,Response}`.
The transport interfaces stay `Client` / `AsyncClient` (they are
clients); only the data shapes lose the prefix.
- Drop the `method` field from `Request` (TS, Rust, Python) and from
the runtime _make_request / _make_sse_request signatures and the
generated client method bodies. Every reflectapi endpoint is POST by
design, so transports hardcode it; carrying "POST" through every
call and DTO was dead surface.
- TS SSE switch back to native `new TextDecoderStream()`. The custom
`__text_decoder_stream` was a TS-variance workaround, not a runtime
improvement. A single `as unknown as ReadableWritablePair<string, Uint8Array>`
cast bridges the BufferSource/Uint8Array variance mismatch in lib.dom.
- TS `__read_response_body` now defers to the platform via
`new (globalThis as any).Response(body).text()` instead of the manual
reader+decoder loop. One line, well-tested, no chunk-boundary debate.
Reviewed and rejected:
- The Codex P2 "avoid serializing absent body as null" — false positive.
The empty-body path produces `b""` and the `if request.body:` guard
at the dispatch site already skips the content kwarg.
Carved out as a follow-up:
- Andrey's `?? "{}"` fallback question: stop sending a body for
endpoints with no input type. Touches the wire protocol on both
client and server, so it's its own PR.1 parent 07cba1a commit db9049c
175 files changed
Lines changed: 764 additions & 638 deletions
File tree
- reflectapi-demo
- clients
- python
- typescript
- src/tests/snapshots
- reflectapi-python-runtime
- src/reflectapi_runtime
- tests
- reflectapi
- src
- codegen
- rust-dependency-stubs
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
514 | 514 | | |
515 | 515 | | |
516 | 516 | | |
517 | | - | |
518 | 517 | | |
519 | 518 | | |
520 | 519 | | |
| |||
541 | 540 | | |
542 | 541 | | |
543 | 542 | | |
544 | | - | |
545 | 543 | | |
546 | 544 | | |
547 | 545 | | |
| |||
566 | 564 | | |
567 | 565 | | |
568 | 566 | | |
569 | | - | |
570 | 567 | | |
571 | 568 | | |
572 | 569 | | |
| |||
602 | 599 | | |
603 | 600 | | |
604 | 601 | | |
605 | | - | |
606 | 602 | | |
607 | 603 | | |
608 | 604 | | |
| |||
624 | 620 | | |
625 | 621 | | |
626 | 622 | | |
627 | | - | |
628 | 623 | | |
629 | 624 | | |
630 | 625 | | |
| |||
651 | 646 | | |
652 | 647 | | |
653 | 648 | | |
654 | | - | |
655 | 649 | | |
656 | 650 | | |
657 | 651 | | |
| |||
677 | 671 | | |
678 | 672 | | |
679 | 673 | | |
680 | | - | |
681 | 674 | | |
682 | 675 | | |
683 | 676 | | |
| |||
703 | 696 | | |
704 | 697 | | |
705 | 698 | | |
706 | | - | |
707 | 699 | | |
708 | 700 | | |
709 | 701 | | |
| |||
746 | 738 | | |
747 | 739 | | |
748 | 740 | | |
749 | | - | |
750 | 741 | | |
751 | 742 | | |
752 | 743 | | |
| |||
773 | 764 | | |
774 | 765 | | |
775 | 766 | | |
776 | | - | |
777 | 767 | | |
778 | 768 | | |
779 | 769 | | |
| |||
798 | 788 | | |
799 | 789 | | |
800 | 790 | | |
801 | | - | |
802 | 791 | | |
803 | 792 | | |
804 | 793 | | |
| |||
834 | 823 | | |
835 | 824 | | |
836 | 825 | | |
837 | | - | |
838 | 826 | | |
839 | 827 | | |
840 | 828 | | |
| |||
856 | 844 | | |
857 | 845 | | |
858 | 846 | | |
859 | | - | |
860 | 847 | | |
861 | 848 | | |
862 | 849 | | |
| |||
883 | 870 | | |
884 | 871 | | |
885 | 872 | | |
886 | | - | |
887 | 873 | | |
888 | 874 | | |
889 | 875 | | |
| |||
909 | 895 | | |
910 | 896 | | |
911 | 897 | | |
912 | | - | |
913 | 898 | | |
914 | 899 | | |
915 | 900 | | |
| |||
935 | 920 | | |
936 | 921 | | |
937 | 922 | | |
938 | | - | |
939 | 923 | | |
940 | 924 | | |
941 | 925 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
15 | 35 | | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
| 36 | + | |
22 | 37 | | |
23 | 38 | | |
24 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
25 | 42 | | |
26 | 43 | | |
27 | 44 | | |
| |||
190 | 207 | | |
191 | 208 | | |
192 | 209 | | |
193 | | - | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
194 | 216 | | |
195 | | - | |
| 217 | + | |
196 | 218 | | |
197 | 219 | | |
198 | 220 | | |
| |||
245 | 267 | | |
246 | 268 | | |
247 | 269 | | |
248 | | - | |
| 270 | + | |
249 | 271 | | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
254 | 276 | | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
255 | 292 | | |
256 | 293 | | |
257 | 294 | | |
258 | | - | |
| 295 | + | |
259 | 296 | | |
260 | 297 | | |
261 | 298 | | |
262 | 299 | | |
263 | | - | |
| 300 | + | |
264 | 301 | | |
265 | 302 | | |
266 | 303 | | |
| |||
284 | 321 | | |
285 | 322 | | |
286 | 323 | | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
287 | 328 | | |
288 | | - | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
289 | 335 | | |
290 | 336 | | |
291 | 337 | | |
292 | 338 | | |
293 | 339 | | |
294 | 340 | | |
295 | 341 | | |
296 | | - | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
297 | 349 | | |
298 | 350 | | |
299 | 351 | | |
| |||
302 | 354 | | |
303 | 355 | | |
304 | 356 | | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
305 | 364 | | |
306 | 365 | | |
307 | 366 | | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
| 367 | + | |
| 368 | + | |
315 | 369 | | |
316 | | - | |
317 | | - | |
318 | | - | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
319 | 373 | | |
320 | 374 | | |
321 | 375 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
0 commit comments