mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-08-11 17:52:10 +00:00
Fixed serialization of PrepareImageResponse
This commit is contained in:
parent
ce32042433
commit
f28a2a8bf9
@ -33,7 +33,7 @@ pub struct PrepareImageRequest {
|
||||
|
||||
/// The prepared image together with the dimensions the caller can lay out against.
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub struct PrepareImageResponse {
|
||||
/// The complete `data:` URL, ready to embed.
|
||||
data_url: String,
|
||||
@ -252,6 +252,26 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn serializes_response_in_snake_case_for_the_rust_service_contract() {
|
||||
let response = PrepareImageResponse {
|
||||
data_url: "data:image/jpeg;base64,/9j/".to_string(),
|
||||
mime_type: "image/jpeg".to_string(),
|
||||
width: 17,
|
||||
height: 11,
|
||||
was_resized: false,
|
||||
};
|
||||
let json = serde_json::to_value(response).unwrap();
|
||||
assert_eq!(json["data_url"], "data:image/jpeg;base64,/9j/");
|
||||
assert_eq!(json["mime_type"], "image/jpeg");
|
||||
assert_eq!(json["width"], 17);
|
||||
assert_eq!(json["height"], 11);
|
||||
assert_eq!(json["was_resized"], false);
|
||||
assert!(json.get("dataUrl").is_none());
|
||||
assert!(json.get("mimeType").is_none());
|
||||
assert!(json.get("wasResized").is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn disabled_optimization_preserves_original_bytes() {
|
||||
let path = temporary_image_path("png");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user