Remove unnecessary macro usage
This commit is contained in:
parent
f0836d4415
commit
ce4946afc1
2 changed files with 13 additions and 21 deletions
|
@ -3,28 +3,19 @@ use crate::schema::*;
|
|||
use crate::JsonSchema;
|
||||
use url::Url;
|
||||
|
||||
macro_rules! formatted_string_impl {
|
||||
($ty:ident, $format:literal) => {
|
||||
formatted_string_impl!($ty, $format, JsonSchema for $ty);
|
||||
};
|
||||
($ty:ident, $format:literal, $($desc:tt)+) => {
|
||||
impl $($desc)+ {
|
||||
impl JsonSchema for Url {
|
||||
no_ref_schema!();
|
||||
|
||||
fn schema_name() -> String {
|
||||
stringify!($ty).to_owned()
|
||||
"Url".to_owned()
|
||||
}
|
||||
|
||||
fn json_schema(_: &mut SchemaGenerator) -> Schema {
|
||||
SchemaObject {
|
||||
instance_type: Some(InstanceType::String.into()),
|
||||
format: Some($format.to_owned()),
|
||||
format: Some("uri".to_owned()),
|
||||
..Default::default()
|
||||
}
|
||||
.into()
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
formatted_string_impl!(Url, "uri");
|
||||
|
|
|
@ -269,6 +269,7 @@ Schemars can implement `JsonSchema` on types from several popular crates, enable
|
|||
- [`uuid`](https://crates.io/crates/uuid) (^0.8)
|
||||
- [`smallvec`](https://crates.io/crates/smallvec) (^1.0)
|
||||
- [`arrayvec`](https://crates.io/crates/arrayvec) (^0.5)
|
||||
- [`url`](https://crates.io/crates/url) (^2.0)
|
||||
*/
|
||||
|
||||
/// The map type used by schemars types.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue