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 {
|
macro_rules! simple_impl {
|
||||||
($type:ty => $instance_type:ident) => {
|
($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) => {
|
($type:ty => $instance_type:ident, $format:literal) => {
|
||||||
simple_impl!($type => $instance_type, Some($format.to_owned()));
|
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 {
|
impl JsonSchema for $type {
|
||||||
no_ref_schema!();
|
no_ref_schema!();
|
||||||
|
|
||||||
fn schema_name() -> String {
|
fn schema_name() -> String {
|
||||||
stringify!($instance_type).to_owned()
|
$name.to_owned()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn json_schema(_: &mut SchemaGenerator) -> Schema {
|
fn json_schema(_: &mut SchemaGenerator) -> Schema {
|
||||||
SchemaObject {
|
SchemaObject {
|
||||||
instance_type: Some(InstanceType::$instance_type.into()),
|
instance_type: Some(InstanceType::$instance_type.into()),
|
||||||
format: $($format)+,
|
format: $format,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
.into()
|
.into()
|
||||||
|
|
|
@ -8,31 +8,14 @@
|
||||||
],
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"inclusive": {
|
"inclusive": {
|
||||||
"$ref": "#/definitions/Range_Of_Number"
|
"$ref": "#/definitions/Range_Of_double"
|
||||||
},
|
},
|
||||||
"range": {
|
"range": {
|
||||||
"$ref": "#/definitions/Range_Of_Integer"
|
"$ref": "#/definitions/Range_Of_uint"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"definitions": {
|
"definitions": {
|
||||||
"Range_Of_Integer": {
|
"Range_Of_double": {
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"end",
|
|
||||||
"start"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"end": {
|
|
||||||
"type": "integer",
|
|
||||||
"format": "uint"
|
|
||||||
},
|
|
||||||
"start": {
|
|
||||||
"type": "integer",
|
|
||||||
"format": "uint"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Range_Of_Number": {
|
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
"end",
|
"end",
|
||||||
|
@ -48,6 +31,23 @@
|
||||||
"format": "double"
|
"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#",
|
"$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",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
"inner",
|
"inner",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
"$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",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
"inner",
|
"inner",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue