fix: make operation marker naming total

This commit is contained in:
2026-09-17 23:28:20 +09:00
parent 633f43530c
commit 019ab57e8f
3 changed files with 33 additions and 3 deletions
+16 -1
View File
@@ -473,7 +473,7 @@ fn normalize_operation(method: &mut TraitItemFn) -> syn::Result<Operation> {
}
Ok(Operation {
marker_ident: format_ident!("{}", to_pascal_case(&method.sig.ident)),
marker_ident: operation_marker_ident(&method.sig.ident),
method_ident: method.sig.ident.clone(),
operation_id,
method: http_method,
@@ -926,6 +926,21 @@ fn ident_text(ident: &Ident) -> String {
value.strip_prefix("r#").unwrap_or(&value).to_owned()
}
fn operation_marker_ident(method: &Ident) -> Ident {
let candidate = to_pascal_case(method);
if let Ok(mut marker) = syn::parse_str::<Ident>(&candidate) {
marker.set_span(method.span());
return marker;
}
let encoded = ident_text(method)
.as_bytes()
.iter()
.map(|byte| format!("{byte:02x}"))
.collect::<String>();
Ident::new(&format!("Operation{encoded}"), method.span())
}
fn to_pascal_case(ident: &Ident) -> String {
ident_text(ident)
.split('_')