-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
warning: failed to parse serde attribute #[serde(rename_all = "camelCase")]
on enum struct variant
#135
Comments
It seems to be an issue with most serde field attributes, I get the same with |
As @escritorio-gustavo mentioned, the |
right now, it's sadly neccessary to rename each field individually with |
My mistake, due to #165 I thought |
Hey @NyxCode... I have forked the repo to start working on a fix. use serde::{Serialize, Deserialize};
use ts_rs::TS;
/// Used enum from issue to test
#[derive(Serialize, Deserialize, TS, Clone)]
#[ts(export)]
#[serde(rename_all = "camelCase")]
pub enum TaskStatus {
#[serde(rename_all = "camelCase")]
Running { started_time: String }, // Changed to string because the `chrono` dependency doesn't include the `serde` flag
#[serde(rename_all = "camelCase")]
Terminated {
status: i32,
stdout: String,
stderr: String,
},
}
#[test]
pub fn enum_struct_variant() {
assert_eq!(TaskStatus::inline(), r#"{ "running": { startedTime: string, } } | { "terminated": { status: number, stdout: string, stderr: string, } }"#)
} And the test is passing... Has the |
The fn format_field(
formatted_fields: &mut Vec<TokenStream>,
dependencies: &mut Dependencies,
field: &Field,
rename_all: &Option<Inflection>,
generics: &Generics,
) -> Result<()> |
@escritorio-gustavo Hey! Since you've already got the test, could you make a PR for that? |
The |
Hello,
I set
#[serde(rename_all = "camelCase")
1 on enum struct variants:But I have the following warnings:
And the generated Typescript for the enum struct variants' fields are in
snake_case
(eg.started_time
).Version:
ts-rs = { version = "6.2.1", features = ["chrono-impl", "uuid-impl"] }
Footnotes
https://serde.rs/variant-attrs.html#rename_all ↩
The text was updated successfully, but these errors were encountered: