Responsible for the schema of the JSON API, as well as for providing types used internally.
(There is a lot of overlap, as there can be, in early versions).
We don't currently do any style transformations, but we have tests to try to ensure they're
always possible.
Here are the transformation rules we use to verify all key names we select can be round-tripped
between styles:
- Add a leading underscore to every group of numbers unless preceded by a lowercase x or y.
/([^xy])([0-9]+)/ with "$1_$2"/
- Add a leading underscore before every uppercase letter:
/[A-Z]/ with "_$0"
- Strip leading underscores from string
/(\A|\s+)_+/ with "$1"
- Collapse all duplicate underscores
replace("__", "_")
- Lowercase the resulting string
- Uppercase every letter following an underscore or word boundary.
Regex::new(r"(_|\b)([a-z])").unwrap().replace_all(&s, |c: &Captures| c[0].to_uppercase())
- Lowercase first character of string
- Delete all underscores from string