Improve schema naming for deriving on remote types

This commit is contained in:
Graham Esau 2019-12-27 15:37:59 +00:00
parent ea28450c30
commit 781f40b061
8 changed files with 36 additions and 23 deletions

View file

@ -16,6 +16,7 @@ use schemars::{schema_for, JsonSchema};
// This is just a copy of the remote data structure that Schemars can use to
// create a suitable JsonSchema impl.
#[derive(JsonSchema)]
#[serde(remote = "Duration")]
pub struct DurationDef {
pub secs: i64,
pub nanos: i32,

View file

@ -11,11 +11,11 @@
"type": "string"
},
"wall_time": {
"$ref": "#/definitions/DurationDef"
"$ref": "#/definitions/Duration"
}
},
"definitions": {
"DurationDef": {
"Duration": {
"type": "object",
"required": [
"nanos",

View file

@ -14,7 +14,7 @@
"default": "0.000000000s",
"allOf": [
{
"$ref": "#/definitions/DurationDef"
"$ref": "#/definitions/Duration"
}
]
},
@ -25,16 +25,16 @@
},
"allOf": [
{
"$ref": "#/definitions/DurationDef"
"$ref": "#/definitions/Duration"
}
]
},
"wall_time": {
"$ref": "#/definitions/DurationDef"
"$ref": "#/definitions/Duration"
}
},
"definitions": {
"DurationDef": {
"Duration": {
"type": "object",
"required": [
"nanos",

View file

@ -10,7 +10,7 @@
],
"properties": {
"byte_or_bool2": {
"$ref": "#/definitions/OrDef_for_uint8_and_Boolean"
"$ref": "#/definitions/Or_for_uint8_and_Boolean"
},
"fake_map": {
"type": "object",
@ -22,14 +22,14 @@
}
},
"s": {
"$ref": "#/definitions/StrDef"
"$ref": "#/definitions/Str"
},
"unit_or_t2": {
"$ref": "#/definitions/OrDef_for_Null_and_int32"
"$ref": "#/definitions/Or_for_Null_and_int32"
}
},
"definitions": {
"OrDef_for_Null_and_int32": {
"Or_for_Null_and_int32": {
"anyOf": [
{
"type": "null"
@ -40,7 +40,7 @@
}
]
},
"OrDef_for_uint8_and_Boolean": {
"Or_for_uint8_and_Boolean": {
"anyOf": [
{
"type": "integer",
@ -52,7 +52,7 @@
}
]
},
"StrDef": {
"Str": {
"type": "string"
}
}