Skip to main content

Module idents

Module idents 

Source
Expand description

Keyword-safe, validated construction of Rust identifiers from OpenAPI names.

OpenAPI operationIds and parameter names are free-form strings, but they are used to name generated Rust methods, struct fields, and types. Feeding an arbitrary string into format_ident! (i.e. proc_macro2::Ident::new) panics when the string is not a legal identifier — for example an op named type/async (a keyword) or one starting with a digit. These helpers turn that panic into either a raw identifier (typer#type) or a clear diagnostic the caller can route through super::operations::Diagnostics.

Functions§

field_ident
Keyword-safe struct-field identifier for a parameter name (snake-cased).
keyword_safe_ident
Infallible keyword-safe identifier for contexts without a diagnostics channel (schema property field names).
method_ident
Keyword-safe method identifier for an operationId (snake-cased).
safe_ident
Turn an already case-converted name into a keyword-safe Ident.
type_ident
Validate an already-assembled type name (e.g. a synthesized query-param enum like ListPetsStatusQuery) and turn it into an Ident.
validate_type_base
Validate that an operationId yields a usable PascalCase base for generated type names ({Base}Request, {Base}Response, {Base}Auth, …).