Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/client_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -877,8 +877,7 @@ impl CodeGenerator {
multipart_filenames: Option<syn::Ident>,
validate_content_type: bool,
) -> ClientMethodPlan<'a> {
let precise_stream = matches!(success.body, ClientSuccessBody::EventStream)
&& (validate_content_type || multipart_filenames.is_some());
let precise_stream = matches!(success.body, ClientSuccessBody::EventStream);
let mut captures = Vec::new();
let request = if precise_stream {
self.generate_request_param_with_capture(operation, Some(&mut captures))
Expand All @@ -900,7 +899,7 @@ impl CodeGenerator {
request
};
let response_type = if precise_stream {
quote! { impl futures_util::Stream<Item = Result<bytes::Bytes, reqwest::Error>> + use<#(#captures),*> }
quote! { impl futures_util::Stream<Item = Result<bytes::Bytes, reqwest::Error>> + 'static + use<#(#captures),*> }
} else if consumption == "parsed_sse" {
quote! { super::sse::BoxSseStream<Result<super::sse::SseEvent<String>, super::sse::StreamingError>> }
} else {
Expand Down
24 changes: 24 additions & 0 deletions tests/client_transport_variants_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ fn spec() -> serde_json::Value {
"application/octet-stream":{"schema":{"type":"string","format":"binary"}}
}}});
document["paths"]["/upload-stream"] = json!({"post":streaming_upload});
document["paths"]["/events"] = json!({"get":{
"operationId":"rawEvents",
"parameters":[{"name":"cursor","in":"query","schema":{"type":"string"}}],
"responses":{"200":{"description":"events","content":{
"text/event-stream":{"schema":{"type":"string"}}
}}}
}});
document["paths"]["/constructor"] =
json!({"get":{"operationId":"new","responses":{"204":{"description":"ok"}}}});
document["paths"]["/keyword"] = json!({"get":{"operationId":"type","responses":{"200":{"description":"ok", "content":{"application/octet-stream":{"schema":{"type":"string","format":"binary"}}}}}}});
Expand Down Expand Up @@ -112,6 +119,7 @@ fn generated_variants_negotiate_stream_and_keep_filenames_request_local() {
"range".into(),
"profile".into(),
"quotedProfile".into(),
"rawEvents".into(),
],
prune_models: true,
}),
Expand Down Expand Up @@ -141,6 +149,8 @@ fn generated_variants_negotiate_stream_and_keep_filenames_request_local() {
.contains("pub async fn upload_with_multipart_filenames_2")
);
assert!(client.content.contains("pub async fn render_binary_stream"));
assert!(client.content.contains("pub async fn raw_events"));
assert!(client.content.contains("use<"));
assert!(
client
.content
Expand Down Expand Up @@ -311,6 +321,20 @@ mod tests {
let _ = client.type_binary_stream().await;
let _ = client.r#type_binary_stream_2().await;
}
#[allow(dead_code)]
async fn boxed_owned_raw_events<'a>(
client: &HttpClient,
cursor: &'a str,
) -> std::pin::Pin<
Box<
dyn futures_util::Stream<Item = Result<bytes::Bytes, reqwest::Error>>
+ 'static,
>,
> {
let stream = client.raw_events(Some(cursor)).await.unwrap();
Box::pin(stream)
}

#[tokio::test]
async fn transports() {
let state = ServerState::default();
Expand Down
50 changes: 25 additions & 25 deletions tests/corpus-manifest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,31 @@
#
# columns: path bytes lines sha256[0:16]
anthropic/REQUIRED_DEPS.toml 669 16 a7f60b37a7334009
anthropic/client.rs 262866 6809 7379e1a672d7143c
anthropic/client.rs 262886 6809 fc97b105e5e66f79
anthropic/mod.rs 444 17 5214bdbc37b918db
anthropic/types.rs 4212914 87145 fab1ac6f632f1101
arcade/REQUIRED_DEPS.toml 576 14 9228e95d38f5078e
arcade/client.rs 343785 8837 09bfc30d7b54a5f0
arcade/client.rs 343884 8843 dd68bb333a916907
arcade/mod.rs 438 17 b55cb3acf5fdbd02
arcade/types.rs 105169 2609 7717f649b6d59880
asana/REQUIRED_DEPS.toml 699 16 4ad61bc1ea5c636a
asana/client.rs 1959860 49405 d9dc5bddd5b9b433
asana/mod.rs 436 17 2390079a5e4e9f74
asana/types.rs 619164 13468 f5722207ddaa92d4
box/REQUIRED_DEPS.toml 771 18 5dbdfe553bf9dbeb
box/client.rs 1734586 45025 a42e656ff689f277
box/client.rs 1734636 45025 6a0f48b8e79bb58b
box/mod.rs 432 17 b40589a066c4b98b
box/types.rs 1281818 33255 9ab3c662ec355a13
browserbase/REQUIRED_DEPS.toml 699 16 4ad61bc1ea5c636a
browserbase/client.rs 108986 2946 6a3e67edf16602ef
browserbase/client.rs 108996 2946 7b1dd36acb36a744
browserbase/mod.rs 448 17 7e721aa1bb802e26
browserbase/types.rs 50190 1258 8a533e945c0a1773
cal-com/REQUIRED_DEPS.toml 625 15 0e0871569054a9ee
cal-com/client.rs 1281022 33372 557d0f7f541c4d26
cal-com/mod.rs 440 17 05fb649563c82805
cal-com/types.rs 1869078 47094 afddc8676879915b
cartesia/REQUIRED_DEPS.toml 669 16 a7f60b37a7334009
cartesia/client.rs 350964 9292 f64a5286de08f6ee
cartesia/client.rs 351139 9302 ac310bd2daa06c46
cartesia/mod.rs 442 17 3c5001b7641597a2
cartesia/types.rs 232348 6354 99d9eeaf841fc4de
cerebras/REQUIRED_DEPS.toml 528 13 d6f1ac00e2426e4d
Expand All @@ -47,7 +47,7 @@ circleci/client.rs 625181 16188 97bb3b9
circleci/mod.rs 442 17 7a8b5691342a9d62
circleci/types.rs 384614 10072 6f277085e1ad9894
cloudflare/REQUIRED_DEPS.toml 787 19 09cccc57db93029b
cloudflare/client.rs 14200770 369993 2d5786e3d7a84e25
cloudflare/client.rs 14201380 369993 1fdaaedfac657071
cloudflare/mod.rs 446 17 ce0e733f646147da
cloudflare/types.rs 16792851 390215 d20ffe23076f5949
coda/REQUIRED_DEPS.toml 672 16 9e666f39c7301c02
Expand All @@ -59,19 +59,19 @@ coingecko/client.rs 446994 12325 acceac4
coingecko/mod.rs 444 17 0059623eabdef914
coingecko/types.rs 278768 6614 eb3ec8a86a40b025
datadog-v2/REQUIRED_DEPS.toml 700 16 e697f0e5afafb53b
datadog-v2/client.rs 5265888 136265 6fb58659f64d0c54
datadog-v2/client.rs 5265997 136271 3b7686881dea4293
datadog-v2/mod.rs 446 17 56e45841c9753096
datadog-v2/types.rs 3897209 98343 90bb9c59aa8f6c03
digitalocean/REQUIRED_DEPS.toml 736 18 21727a31b033ca36
digitalocean/client.rs 3863496 99335 c27487a416996216
digitalocean/client.rs 3863638 99343 53bab089f111c56b
digitalocean/mod.rs 450 17 3b99e8d4d3161f03
digitalocean/types.rs 1548370 36436 59bc59352b81284a
discord/REQUIRED_DEPS.toml 699 16 4ad61bc1ea5c636a
discord/client.rs 1082325 28233 effe3b33275f7159
discord/client.rs 1082335 28233 0c5554e4ab9b24d5
discord/mod.rs 440 17 1d9f7eee6c834b1c
discord/types.rs 1843460 46571 63bbe5e6b4fc30d4
gcore/REQUIRED_DEPS.toml 746 17 7f467fcbfe949464
gcore/client.rs 5203496 137184 caf9456aa1b50703
gcore/client.rs 5203526 137184 7ede00ff22518a72
gcore/mod.rs 436 17 d5c05d8821f23bcb
gcore/types.rs 6016429 140206 f72406948cf03e54
github/REQUIRED_DEPS.toml 625 15 0e0871569054a9ee
Expand Down Expand Up @@ -107,7 +107,7 @@ grafana/client.rs 1894803 48979 8f52fb0
grafana/mod.rs 440 17 7b59b00331edb605
grafana/types.rs 391878 9248 e82c5cd4fb60daf2
groq/REQUIRED_DEPS.toml 630 15 7935666e65c0812e
groq/client.rs 147235 3849 0c6f32f186b6ae0a
groq/client.rs 147278 3851 dfc5b9c0961e526b
groq/mod.rs 434 17 72fd6d54577d5597
groq/types.rs 389823 9789 a01c6e96836c8b5a
imagekit/REQUIRED_DEPS.toml 673 16 b888661e2699f921
Expand All @@ -131,7 +131,7 @@ launchdarkly/client.rs 2541636 64641 5fd6a67
launchdarkly/mod.rs 450 17 d4ed5579304ccd39
launchdarkly/types.rs 743840 18512 0c2344469fafd51e
letta/REQUIRED_DEPS.toml 746 17 7f467fcbfe949464
letta/client.rs 1528973 40829 ea1b4cdcf43cb70f
letta/client.rs 1529109 40833 24c0f009efef33d2
letta/mod.rs 436 17 5cc3226a7c317d2a
letta/types.rs 6955920 141632 ef6251b6ee3d7f91
lithic/REQUIRED_DEPS.toml 688 17 9c8fe0ad1f161983
Expand All @@ -143,31 +143,31 @@ luma/client.rs 59518 1615 5f1fe1b
luma/mod.rs 434 17 d85018b8cdd8f625
luma/types.rs 82848 2293 4dd743ed513956f8
meta-llama/REQUIRED_DEPS.toml 630 15 7935666e65c0812e
meta-llama/client.rs 64366 1679 4c85be1cf76792aa
meta-llama/client.rs 64399 1681 375c3c768f9986f1
meta-llama/mod.rs 446 17 6e485725d643b7c2
meta-llama/types.rs 97541 2408 2bd9da2ef77022e0
microsoft-graph/REQUIRED_DEPS.toml 674 16 e864ec8321bc90dc
microsoft-graph/client.rs 110202062 2682960 b9636c10e6bb617b
microsoft-graph/client.rs 110206174 2683008 7e63b3b31ef91d86
microsoft-graph/mod.rs 456 17 b99d7781b4460b5d
microsoft-graph/types.rs 15241507 390543 ee7db4cd80762807
modern-treasury/REQUIRED_DEPS.toml 746 17 7f467fcbfe949464
modern-treasury/client.rs 968508 26001 10421b2b792da46b
modern-treasury/mod.rs 456 17 5f336a50419a709b
modern-treasury/types.rs 1005013 26859 4617c87b9896c411
openai/REQUIRED_DEPS.toml 648 15 a3db003e7f3781e2
openai/client.rs 1266151 33841 01108431b6d0c2a2
openai/client.rs 1266488 33859 b317ca713ed4c495
openai/mod.rs 438 17 59c0207149335235
openai/types.rs 6329163 142793 e9466bc79da37e1f
opencode/REQUIRED_DEPS.toml 576 14 9228e95d38f5078e
opencode/client.rs 955638 25391 b30d37da3f2d6585
opencode/client.rs 955931 25401 2b4aa344b2001bda
opencode/mod.rs 442 17 98c109eb94b95dbf
opencode/types.rs 6820664 146287 4e38f9d8cbd1024e
pagerduty/REQUIRED_DEPS.toml 672 16 9e666f39c7301c02
pagerduty/client.rs 2168498 58187 0a0bf3f7f6db74a0
pagerduty/mod.rs 444 17 2edbc04dfe892a50
pagerduty/types.rs 2058127 49376 e7800d4fc1435ac1
perplexity/REQUIRED_DEPS.toml 623 15 86a1a17387cf7108
perplexity/client.rs 62799 1639 fc88f7694cdfadc3
perplexity/client.rs 62832 1641 118b0d48291491c1
perplexity/mod.rs 446 17 1f9103fe36426530
perplexity/types.rs 530449 12140 0456b118c51b5e00
resend/REQUIRED_DEPS.toml 674 16 e864ec8321bc90dc
Expand Down Expand Up @@ -195,44 +195,44 @@ spotify/client.rs 563501 14797 7303567
spotify/mod.rs 440 17 954184fb7fd84586
spotify/types.rs 261914 6374 ec3db89e1975c7b0
storyden/REQUIRED_DEPS.toml 698 17 569479aa8197c912
storyden/client.rs 1044933 27432 02a90b3d99a404f3
storyden/client.rs 1045134 27440 65f9830f12e661a3
storyden/mod.rs 442 17 ff7a510276d50e59
storyden/types.rs 887093 20176 96f969322e485cda
stripe/REQUIRED_DEPS.toml 601 15 de8d722a8a5cb828
stripe/client.rs 2908755 75495 9b1a1398e88b5628
stripe/client.rs 2908765 75495 9dde3373afef430e
stripe/mod.rs 438 17 cafa363545854cd3
stripe/types.rs 10236263 251226 b873858074f50db2
supabase/REQUIRED_DEPS.toml 697 17 f2fa59b2eb1837a1
supabase/client.rs 602597 16288 dbc12101b4ae678e
supabase/mod.rs 442 17 331ec75d430bc0a8
supabase/types.rs 501018 13981 a90e47b6926d92a1
telnyx/REQUIRED_DEPS.toml 787 19 09cccc57db93029b
telnyx/client.rs 5442514 142736 48ffd94b6422c56b
telnyx/client.rs 5442660 142740 178fa3b9163ad7c7
telnyx/mod.rs 438 17 f3a44d93d532e621
telnyx/types.rs 4501474 108106 c72e842eb8b25f1c
terminal-shop/REQUIRED_DEPS.toml 529 14 241dda1403a4b0ba
terminal-shop/client.rs 208120 5561 e896ba15ff57c29a
terminal-shop/mod.rs 452 17 7014abd4e66e4e4e
terminal-shop/types.rs 62233 1872 5c0e2ce07125c290
together/REQUIRED_DEPS.toml 762 18 2357560c3a71c3c6
together/client.rs 574607 15043 22f6ff6074463c3f
together/client.rs 574825 15055 4c5ce8caed48692f
together/mod.rs 442 17 69fe71a3ff6db06e
together/types.rs 682848 17401 7f831820a1cb4aae
twilio/REQUIRED_DEPS.toml 650 16 79c204ac31d0efe3
twilio/client.rs 844086 22156 b1ce00b1b35715a7
twilio/mod.rs 438 17 1e85ee5c08c46793
twilio/types.rs 895681 20820 37d493aaebf60a09
val-town/REQUIRED_DEPS.toml 720 17 4d0f659a2898dcf4
val-town/client.rs 177213 4682 8ef4dff5f8a4afa4
val-town/client.rs 177233 4682 73f4a3ab345740d7
val-town/mod.rs 442 17 8a07cd572c0c8638
val-town/types.rs 68086 1978 78ac613c49efff35
vercel/REQUIRED_DEPS.toml 673 16 b888661e2699f921
vercel/client.rs 1511116 39678 204db912170875f6
vercel/client.rs 1511136 39678 124586336afef632
vercel/mod.rs 438 17 6e4cb11d3c843a23
vercel/types.rs 15047218 383523 325ce33d9e507225
writer/REQUIRED_DEPS.toml 720 17 4d0f659a2898dcf4
writer/client.rs 190458 4984 6a8b2964d327c1ab
writer/client.rs 190577 4990 9b2d6e5c683a7bc4
writer/mod.rs 438 17 0435bf1552e493d1
writer/types.rs 198394 4888 800dd8afe5798530
#
# specs: 56 files: 224 bytes: 331087352
# specs: 56 files: 224 bytes: 331094328
Loading