Module route_naming
Expand description
Canonical REST route-segment derivation for a model name.
cratestack#345: three independently-implemented algorithms (the
server’s real Axum route registration in
cratestack-macros::axum::model::routes, and near-identical
split_words-based reimplementations in
cratestack-client-typescript::naming and
cratestack-client-dart::idents) all computed what is supposed to be
the same wire contract — a model’s REST route path — and drifted apart
for model names containing a literal _ (legal today; no parser
grammar restriction). to_snake_case/pluralize here are exactly the
server’s original algorithm, byte-for-byte, moved into this crate
(already a shared dependency of cratestack-macros,
cratestack-client-typescript, and cratestack-client-dart) so every
consumer imports the same implementation instead of reimplementing it.
Do not reimplement these. Any code deriving a model’s REST route
must call model_route_segment (or to_snake_case + pluralize
directly, in that order) from here.
Functions§
- model_
route_ segment - The canonical REST route segment (no leading
/) for a model name —pluralize(&to_snake_case(model_name)). The server’s Axum route registration and every client generator’s route derivation must produce this exact string for a given model name; call this instead of composingto_snake_case/pluralizelocally so the composition order can’t drift either. - pluralize
- English pluralization used for both REST route segments and generated
table/column names — the single implementation
cratestack-coreandcratestack-migrateboth call (cratestack#504; previously two hand-synced copies,cratestack-migrate::naming::pluralizemirroring this one, that had already drifted apart on this exact rule). - to_
snake_ case - Converts
valueto snake_case by inserting a single_before every non-initial uppercase character. Every other character — including any pre-existing_— passes through unchanged.