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 crate::JsonSchema;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
macro_rules! formatted_string_impl {
|
impl JsonSchema for Url {
|
||||||
($ty:ident, $format:literal) => {
|
no_ref_schema!();
|
||||||
formatted_string_impl!($ty, $format, JsonSchema for $ty);
|
|
||||||
};
|
|
||||||
($ty:ident, $format:literal, $($desc:tt)+) => {
|
|
||||||
impl $($desc)+ {
|
|
||||||
no_ref_schema!();
|
|
||||||
|
|
||||||
fn schema_name() -> String {
|
fn schema_name() -> String {
|
||||||
stringify!($ty).to_owned()
|
"Url".to_owned()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn json_schema(_: &mut SchemaGenerator) -> Schema {
|
fn json_schema(_: &mut SchemaGenerator) -> Schema {
|
||||||
SchemaObject {
|
SchemaObject {
|
||||||
instance_type: Some(InstanceType::String.into()),
|
instance_type: Some(InstanceType::String.into()),
|
||||||
format: Some($format.to_owned()),
|
format: Some("uri".to_owned()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
|
||||||
.into()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
.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)
|
- [`uuid`](https://crates.io/crates/uuid) (^0.8)
|
||||||
- [`smallvec`](https://crates.io/crates/smallvec) (^1.0)
|
- [`smallvec`](https://crates.io/crates/smallvec) (^1.0)
|
||||||
- [`arrayvec`](https://crates.io/crates/arrayvec) (^0.5)
|
- [`arrayvec`](https://crates.io/crates/arrayvec) (^0.5)
|
||||||
|
- [`url`](https://crates.io/crates/url) (^2.0)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/// The map type used by schemars types.
|
/// The map type used by schemars types.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue