google-cloud-rust icon indicating copy to clipboard operation
google-cloud-rust copied to clipboard

cleanup: remove unnecessary #[serde_with::serde_as] attributes from oneofs

Open suzmue opened this issue 9 months ago • 2 comments

#2030 added support for custom serialization of types within a oneof, however it also added some #[serde_with::serde_as] attributes to all oneofs, even if they weren't necessary. Cleanup the generator to only generate the attribute when actually necessary.

suzmue avatar May 08 '25 18:05 suzmue

At some point we should ask ourselves if it is simpler to generate the impl serde::de::Deserialize Foo { ... } and impl serde::ser::Serialize for Foo { ... } instead of using the #[derive(... Serialize, Deserialize)] macros and the attributes. We have at least one attribute per field now, we may be better off just writing the code ourselves.

coryan avatar May 08 '25 20:05 coryan

Crazy idea: we write our own proc-macro: https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros

And maybe we make it public so applications can also #[derive(GoogleSerde)] on their own types.

dbolduc avatar May 08 '25 21:05 dbolduc

This is stale, we no longer generate any serde attributes for oneof, or messages for that matter.

coryan avatar Aug 10 '25 15:08 coryan