arcstr icon indicating copy to clipboard operation
arcstr copied to clipboard

Support schemars

Open JohnScience opened this issue 8 months ago • 1 comments

Crate: https://docs.rs/schemars/0.8.22/schemars/.

Support can be enabled via a feature. What it takes a simple derive. Maybe I can do that later.

As a temporary fix, I did

// We can't derive `JsonSchema` because `ArcStr` doesn't implement it
// and we can't implement it for `ArcStr` because
// both `JsonSchema` trait and `ArcStr` type are external to this crate.
impl JsonSchema for IString {
    fn schema_name() -> String {
        "IString".to_string()
    }

    fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
        <String as JsonSchema>::json_schema(gen)
    }
}

JohnScience avatar Apr 22 '25 03:04 JohnScience

I understand there is no schemars support in arcstr. Wouldn't it also be nice to have arcstr support in schemars in addition to smol_str? 😄

reneleonhardt avatar Aug 26 '25 15:08 reneleonhardt