Open drahnr opened 1 month ago
Oof. Yeah, there's a reason this is issue 1! https://github.com/oxidecomputer/typify/issues/1
What could would you ideally like to see generated?
I think I'd want to see something like a configurable prefix for disambiguation, or some structural suffix mapping i.e. {orig}_1
or similar. All of them suffer from deferring the collision one level away but doesn't fix the root cause systematically
In a perfect world the upstream would amend the spec, for the particular vendor, that won't happen unfortunately 😕
Thinking about this some more: What I really want, is a closure (FnMut
of some sort) to be passable for ident
normalization, which gives a context
of some sort if it's going to be a field name, a function name, or struct name.
Setting aside the mechanism: what code would you like to see generated in this case?
Setting aside the mechanism: what code would you like to see generated in this case?
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Foo {
#[serde(rename = "M")]
pub m__disambiguation_case_1: bool,
pub m: bool,
}
Given that depending on the context, any suffix will risk a collision, that was what motivated the user defined closure for normalization (with a sane default).
An externally provided
openapi
spec file defineswhich generates
which won't compile. The root here is the normalization of the identifiers to be lowercase.