openapi_to_rust/http_config.rs
1//! Runtime HTTP client configuration types
2//!
3//! These types are used by generated code at runtime and represent the actual
4//! configuration that will be used by the HTTP client.
5
6use std::collections::HashMap;
7
8/// Runtime HTTP client configuration (used by generated code)
9#[derive(Debug, Clone)]
10pub struct HttpClientConfig {
11 /// Base URL for all API requests
12 pub base_url: Option<String>,
13 /// Request timeout in seconds
14 pub timeout_seconds: Option<u64>,
15 /// Maximum response-body bytes buffered in memory
16 pub max_response_body_bytes: Option<usize>,
17 /// Default headers to include in all requests
18 pub default_headers: HashMap<String, String>,
19}
20
21/// Retry configuration for HTTP requests
22#[derive(Debug, Clone)]
23pub struct RetryConfig {
24 /// Maximum number of retry attempts
25 pub max_retries: u32,
26 /// Initial delay in milliseconds before first retry
27 pub initial_delay_ms: u64,
28 /// Maximum delay in milliseconds between retries
29 pub max_delay_ms: u64,
30}
31
32/// Authentication configuration
33#[derive(Debug, Clone)]
34pub enum AuthConfig {
35 /// Bearer token authentication (e.g., "Authorization: Bearer TOKEN")
36 Bearer {
37 /// Header name for the bearer token (default: "Authorization")
38 header_name: String,
39 },
40 /// API key authentication (e.g., "X-API-Key: YOUR_KEY")
41 ApiKey {
42 /// Header name for the API key
43 header_name: String,
44 },
45 /// Custom authentication with configurable header and prefix
46 Custom {
47 /// Header name for the authentication token
48 header_name: String,
49 /// Optional prefix for the header value (e.g., "Bearer ")
50 header_value_prefix: Option<String>,
51 },
52}