Closed aidanwolter3 closed 6 months ago
Thanks for the question! Sadly no, that wouldn't be the right thing to do, because it would mean that none of the many crates that schemars depends on could depend on camino.
However you can do what I did at work, and use this very simple impl:
fn path_schema(gen: &mut SchemaGenerator) -> Schema {
let mut schema: SchemaObject = <String>::json_schema(gen).into();
schema.format = Some("Utf8PathBuf".to_owned());
schema.into()
}
and annotate your schema with #[schemars(schema_with = "path_schema")]
.
This is too trivial to be copyrightable, but in case it ever is, consider this to be CC0-1.0.
I would like to use the
schemars
crate in a project that heavily usescamino
, but am currently prevented from doing so becauseUtf8Path[Buf]
does not implementschemars::JsonSchema
.This PR in
schemars
has not gone anywhere because the maintainer has not reviewed it. https://github.com/GREsau/schemars/pull/214Could we add these impls in
camino
instead?