-
-
Notifications
You must be signed in to change notification settings - Fork 229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
impl JsonSchema for basic camino types #214
base: master
Are you sure you want to change the base?
Conversation
Is this gonna be merged soon ? |
I am also looking forward to when this will merge. We use |
(camino maintainer here) Meanwhile, you can use this really 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 schemas with You can do something similar for This is too trivial to be copyrightable, but in case it ever is, consider this to be CC0-1.0. |
no_ref_schema!(); | ||
|
||
fn schema_name() -> String { | ||
"String".to_owned() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So hmmmm...
I think this shouldn't be String
, I believe -- it should be something more specific like Utf8PathBuf
.
This goes into the format
field in the OpenAPI and JSON schema spec. There are some defined formats, but otherwise it's an open universe (based on https://swagger.io/docs/specification/data-models/data-types/ and https://json-schema.org/understanding-json-schema/reference/string#format).
But maybe this should be exposed as a custom field on the side, e.g. x-rust-type
. @ahl do you have thoughts?
sunshowers's comment works for me! Thank you @sunshowers . |
I'd like to be able to use Utf8Path and Utf8PathBuf like the std equivalents when deriving JsonSchema. I believe the implementation is the same as for those types over in
primitives
.There should be a
camino
feature that gates this based on the optional dependency.