Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

fix: move account struct to app-server-protocol and use camelCase (#5829)

Owen Lin67a219ffc2c0
diff --git a/codex-rs/app-server-protocol/src/protocol.rs b/codex-rs/app-server-protocol/src/protocol.rs
index f164ce5601..65a233a376 100644
--- a/codex-rs/app-server-protocol/src/protocol.rs
+++ b/codex-rs/app-server-protocol/src/protocol.rs
@@ -5,7 +5,7 @@ use crate::JSONRPCNotification;
use crate::JSONRPCRequest;
use crate::RequestId;
use codex_protocol::ConversationId;
-use codex_protocol::account::Account;
+use codex_protocol::account::PlanType;
use codex_protocol::config_types::ForcedLoginMethod;
use codex_protocol::config_types::ReasoningEffort;
use codex_protocol::config_types::ReasoningSummary;
@@ -236,6 +236,22 @@ client_request_definitions! {
},
}
+#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)]
+#[serde(tag = "type", rename_all = "camelCase")]
+#[ts(tag = "type")]
+pub enum Account {
+ #[serde(rename = "apiKey", rename_all = "camelCase")]
+ #[ts(rename = "apiKey", rename_all = "camelCase")]
+ ApiKey { api_key: String },
+
+ #[serde(rename = "chatgpt", rename_all = "camelCase")]
+ #[ts(rename = "chatgpt", rename_all = "camelCase")]
+ ChatGpt {
+ email: Option<String>,
+ plan_type: PlanType,
+ },
+}
+
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
pub struct GetAccountResponse {
@@ -1246,6 +1262,35 @@ mod tests {
Ok(())
}
+ #[test]
+ fn account_serializes_fields_in_camel_case() -> Result<()> {
+ let api_key = Account::ApiKey {
+ api_key: "secret".to_string(),
+ };
+ assert_eq!(
+ json!({
+ "type": "apiKey",
+ "apiKey": "secret",
+ }),
+ serde_json::to_value(&api_key)?,
+ );
+
+ let chatgpt = Account::ChatGpt {
+ email: Some("[email protected]".to_string()),
+ plan_type: PlanType::Plus,
+ };
+ assert_eq!(
+ json!({
+ "type": "chatgpt",
+ "email": "[email protected]",
+ "planType": "plus",
+ }),
+ serde_json::to_value(&chatgpt)?,
+ );
+
+ Ok(())
+ }
+
#[test]
fn serialize_list_models() -> Result<()> {
let request = ClientRequest::ListModels {
diff --git a/codex-rs/protocol/src/account.rs b/codex-rs/protocol/src/account.rs
index 1d63910c64..fb707c3a73 100644
--- a/codex-rs/protocol/src/account.rs
+++ b/codex-rs/protocol/src/account.rs
@@ -18,18 +18,3 @@ pub enum PlanType {
#[serde(other)]
Unknown,
}
-
-#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, JsonSchema, TS)]
-#[serde(tag = "type")]
-#[ts(tag = "type")]
-pub enum Account {
- ApiKey {
- api_key: String,
- },
- #[serde(rename = "chatgpt")]
- #[ts(rename = "chatgpt")]
- ChatGpt {
- email: Option<String>,
- plan_type: PlanType,
- },
-}