switch from unicode_xid to unicode_ident (#73)
This commit is contained in:
parent
3bc3d5972b
commit
24fb7b9611
|
@ -949,7 +949,7 @@ dependencies = [
|
||||||
"syn",
|
"syn",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"typify",
|
"typify",
|
||||||
"unicode-xid",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
@ -21,7 +21,7 @@ serde_json = "1.0"
|
||||||
syn = { version = "1.0", features = ["parsing"] }
|
syn = { version = "1.0", features = ["parsing"] }
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
typify = "0.0.8"
|
typify = "0.0.8"
|
||||||
unicode-xid = "0.2"
|
unicode-ident = "1.0.0"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
dropshot = { git = "https://github.com/oxidecomputer/dropshot", default-features = false }
|
dropshot = { git = "https://github.com/oxidecomputer/dropshot", default-features = false }
|
||||||
|
|
|
@ -4,7 +4,7 @@ use indexmap::IndexMap;
|
||||||
use openapiv3::{
|
use openapiv3::{
|
||||||
Components, Parameter, ReferenceOr, RequestBody, Response, Schema,
|
Components, Parameter, ReferenceOr, RequestBody, Response, Schema,
|
||||||
};
|
};
|
||||||
use unicode_xid::UnicodeXID;
|
use unicode_ident::{is_xid_continue, is_xid_start};
|
||||||
|
|
||||||
use crate::Result;
|
use crate::Result;
|
||||||
|
|
||||||
|
@ -82,13 +82,13 @@ pub(crate) fn sanitize(input: &str, case: Case) -> String {
|
||||||
_ => to_case(
|
_ => to_case(
|
||||||
&input
|
&input
|
||||||
.replace("'", "")
|
.replace("'", "")
|
||||||
.replace(|c: char| !c.is_xid_continue(), "-"),
|
.replace(|c: char| !is_xid_continue(c), "-"),
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
let out = match out.chars().next() {
|
let out = match out.chars().next() {
|
||||||
None => to_case("x"),
|
None => to_case("x"),
|
||||||
Some(c) if c.is_xid_start() => out,
|
Some(c) if is_xid_start(c) => out,
|
||||||
Some(_) => format!("_{}", out),
|
Some(_) => format!("_{}", out),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue