k8s-pb icon indicating copy to clipboard operation
k8s-pb copied to clipboard

Handle irregular camelCase to snake_case conversion

Open kazk opened this issue 4 years ago • 2 comments

Some irregular camel case to snake case conversions are failing (e.g., clusterIPs becomes cluster_i_ps). But prost_build doesn't provide a way to fix this at the moment.

kazk avatar Aug 24 '21 05:08 kazk

Is there an upstream issue for this? Had a bit of a look, and nothing matching AFAIKT. But I did see people saying they could inject serde annotations to certain types in the config with https://docs.rs/prost-build/0.9.0/prost_build/struct.Config.html#method.type_attribute :

let mut config = prost_build::Config::new();
config.type_attribute(".", "#[derive(Serialize)]");
config.type_attribute(".", "#[serde(rename_all = \"camelCase\")]");

also there are people looping* over the output to do stuff (here just a rename) we could in the worst-case to a search and replace on the file :|

Anyway, if there is no upstream issue for this we should raise one if needed.

clux avatar Oct 29 '21 22:10 clux

I don't think so. https://github.com/tokio-rs/prost/issues/207 is kind of similar (preserving the original name can be done by passing an identity function).

kazk avatar Oct 29 '21 22:10 kazk

Looking at this again. We can indeed mass replace known broken names at the end.

I did this for the type names in https://github.com/kube-rs/k8s-pb/pull/49 for alignment with type names in k8s-openapi, so i think it makes more sense now.

clux avatar Oct 13 '24 18:10 clux