Skip to main content

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    /// Default headers to include in all requests
16    pub default_headers: HashMap<String, String>,
17}
18
19/// Retry configuration for HTTP requests
20#[derive(Debug, Clone)]
21pub struct RetryConfig {
22    /// Maximum number of retry attempts
23    pub max_retries: u32,
24    /// Initial delay in milliseconds before first retry
25    pub initial_delay_ms: u64,
26    /// Maximum delay in milliseconds between retries
27    pub max_delay_ms: u64,
28}
29
30/// Authentication configuration
31#[derive(Debug, Clone)]
32pub enum AuthConfig {
33    /// Bearer token authentication (e.g., "Authorization: Bearer TOKEN")
34    Bearer {
35        /// Header name for the bearer token (default: "Authorization")
36        header_name: String,
37    },
38    /// API key authentication (e.g., "X-API-Key: YOUR_KEY")
39    ApiKey {
40        /// Header name for the API key
41        header_name: String,
42    },
43    /// Custom authentication with configurable header and prefix
44    Custom {
45        /// Header name for the authentication token
46        header_name: String,
47        /// Optional prefix for the header value (e.g., "Bearer ")
48        header_value_prefix: Option<String>,
49    },
50}