-
Notifications
You must be signed in to change notification settings - Fork 122
Inconsistent behavior with serde rename_all #285
Copy link
Copy link
Open
Description
Here's a simple reproduction of my issue:
Cargo.toml:
[package]
name = "kotlin-typeshare-repro"
version = "0.1.0"
edition = "2024"
[dependencies]
serde = "1.0.228"
serde_json = "1.0.149"
typeshare = "1.0.5"src/lib.rs:
use serde::{Deserialize, Serialize};
use typeshare::typeshare;
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
#[typeshare]
pub enum DocumentType {
PodcastEpisode,
Podcast,
PDF,
}
#[test]
fn test() {
let v = DocumentType::PDF;
assert_eq!(serde_json::to_string(&v).unwrap(), "\"p_d_f\"");
}The test passes, you can see the (weird) "p_d_f" string that gets generated here.
However, if I run typeshare --lang kotlin --output-file Generated.kt . in the project, I get:
enum class DocumentType(val string: String) {
@SerialName("podcast_episode")
PodcastEpisode("podcast_episode"),
@SerialName("podcast")
Podcast("podcast"),
@SerialName("pdf")
PDF("pdf"),
}Which has the serialization "pdf" not "p_d_f", which breaks compatibility between the rust and kotlin versions of this type.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels