Schemas with different "format"s should have different names
This commit is contained in:
parent
fe861ac3a1
commit
09d76c93e4
4 changed files with 20 additions and 20 deletions
|
@ -6,23 +6,23 @@ use std::path::{Path, PathBuf};
|
|||
|
||||
macro_rules! simple_impl {
|
||||
($type:ty => $instance_type:ident) => {
|
||||
simple_impl!($type => $instance_type, None);
|
||||
simple_impl!($type => $instance_type, stringify!($instance_type), None);
|
||||
};
|
||||
($type:ty => $instance_type:ident, $format: literal) => {
|
||||
simple_impl!($type => $instance_type, Some($format.to_owned()));
|
||||
($type:ty => $instance_type:ident, $format:literal) => {
|
||||
simple_impl!($type => $instance_type, $format, Some($format.to_owned()));
|
||||
};
|
||||
($type:ty => $instance_type:ident, $($format:tt)+) => {
|
||||
($type:ty => $instance_type:ident, $name:expr, $format:expr) => {
|
||||
impl JsonSchema for $type {
|
||||
no_ref_schema!();
|
||||
|
||||
fn schema_name() -> String {
|
||||
stringify!($instance_type).to_owned()
|
||||
$name.to_owned()
|
||||
}
|
||||
|
||||
fn json_schema(_: &mut SchemaGenerator) -> Schema {
|
||||
SchemaObject {
|
||||
instance_type: Some(InstanceType::$instance_type.into()),
|
||||
format: $($format)+,
|
||||
format: $format,
|
||||
..Default::default()
|
||||
}
|
||||
.into()
|
||||
|
|
|
@ -8,31 +8,14 @@
|
|||
],
|
||||
"properties": {
|
||||
"inclusive": {
|
||||
"$ref": "#/definitions/Range_Of_Number"
|
||||
"$ref": "#/definitions/Range_Of_double"
|
||||
},
|
||||
"range": {
|
||||
"$ref": "#/definitions/Range_Of_Integer"
|
||||
"$ref": "#/definitions/Range_Of_uint"
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"Range_Of_Integer": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"end",
|
||||
"start"
|
||||
],
|
||||
"properties": {
|
||||
"end": {
|
||||
"type": "integer",
|
||||
"format": "uint"
|
||||
},
|
||||
"start": {
|
||||
"type": "integer",
|
||||
"format": "uint"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Range_Of_Number": {
|
||||
"Range_Of_double": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"end",
|
||||
|
@ -48,6 +31,23 @@
|
|||
"format": "double"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Range_Of_uint": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"end",
|
||||
"start"
|
||||
],
|
||||
"properties": {
|
||||
"end": {
|
||||
"type": "integer",
|
||||
"format": "uint"
|
||||
},
|
||||
"start": {
|
||||
"type": "integer",
|
||||
"format": "uint"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "a-new-name-Array_Of_String-Integer-Integer",
|
||||
"title": "a-new-name-Array_Of_String-int32-int32",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"inner",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "MyStruct_For_Integer_And_Null_And_Boolean_And_Array_Of_String",
|
||||
"title": "MyStruct_For_int32_And_Null_And_Boolean_And_Array_Of_String",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"inner",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue