Refactor flatten
and move it to _private
, remove TempFixupForTests
, regenerate test schemas
This commit is contained in:
parent
18300c67bb
commit
c4d42ec11a
45 changed files with 280 additions and 330 deletions
|
@ -8,7 +8,7 @@
|
|||
"items": {
|
||||
"type": "integer",
|
||||
"format": "uint8",
|
||||
"minimum": 0.0
|
||||
"minimum": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -16,7 +16,7 @@
|
|||
"items": {
|
||||
"type": "integer",
|
||||
"format": "uint8",
|
||||
"minimum": 0.0
|
||||
"minimum": 0
|
||||
}
|
||||
}
|
||||
],
|
||||
|
|
|
@ -33,10 +33,10 @@
|
|||
}
|
||||
},
|
||||
"required": [
|
||||
"weekday",
|
||||
"date_time",
|
||||
"naive_date",
|
||||
"naive_date_time",
|
||||
"naive_time",
|
||||
"weekday"
|
||||
"naive_time"
|
||||
]
|
||||
}
|
|
@ -13,7 +13,7 @@
|
|||
}
|
||||
},
|
||||
"required": [
|
||||
"bar",
|
||||
"foo"
|
||||
"foo",
|
||||
"bar"
|
||||
]
|
||||
}
|
|
@ -30,8 +30,8 @@
|
|||
}
|
||||
},
|
||||
"required": [
|
||||
"deprecated_field",
|
||||
"foo"
|
||||
"foo",
|
||||
"deprecated_field"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
},
|
||||
"deprecated": true,
|
||||
"required": [
|
||||
"deprecated_field",
|
||||
"foo"
|
||||
"foo",
|
||||
"deprecated_field"
|
||||
]
|
||||
}
|
|
@ -21,17 +21,17 @@
|
|||
"nanos": {
|
||||
"type": "integer",
|
||||
"format": "uint32",
|
||||
"minimum": 0.0
|
||||
"minimum": 0
|
||||
},
|
||||
"secs": {
|
||||
"type": "integer",
|
||||
"format": "uint64",
|
||||
"minimum": 0.0
|
||||
"minimum": 0
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"nanos",
|
||||
"secs"
|
||||
"secs",
|
||||
"nanos"
|
||||
]
|
||||
},
|
||||
"SystemTime": {
|
||||
|
@ -40,17 +40,17 @@
|
|||
"nanos_since_epoch": {
|
||||
"type": "integer",
|
||||
"format": "uint32",
|
||||
"minimum": 0.0
|
||||
"minimum": 0
|
||||
},
|
||||
"secs_since_epoch": {
|
||||
"type": "integer",
|
||||
"format": "uint64",
|
||||
"minimum": 0.0
|
||||
"minimum": 0
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"nanos_since_epoch",
|
||||
"secs_since_epoch"
|
||||
"secs_since_epoch",
|
||||
"nanos_since_epoch"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,8 +35,8 @@
|
|||
},
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"c",
|
||||
"t"
|
||||
"t",
|
||||
"c"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -54,8 +54,8 @@
|
|||
},
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"c",
|
||||
"t"
|
||||
"t",
|
||||
"c"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -73,8 +73,8 @@
|
|||
},
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"c",
|
||||
"t"
|
||||
"t",
|
||||
"c"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -93,8 +93,8 @@
|
|||
},
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"bar",
|
||||
"foo"
|
||||
"foo",
|
||||
"bar"
|
||||
]
|
||||
},
|
||||
"t": {
|
||||
|
@ -106,8 +106,8 @@
|
|||
},
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"c",
|
||||
"t"
|
||||
"t",
|
||||
"c"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -136,8 +136,8 @@
|
|||
},
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"c",
|
||||
"t"
|
||||
"t",
|
||||
"c"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -171,8 +171,8 @@
|
|||
},
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"c",
|
||||
"t"
|
||||
"t",
|
||||
"c"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
@ -189,8 +189,8 @@
|
|||
}
|
||||
},
|
||||
"required": [
|
||||
"bar",
|
||||
"foo"
|
||||
"foo",
|
||||
"bar"
|
||||
]
|
||||
},
|
||||
"UnitStruct": {
|
||||
|
|
|
@ -33,8 +33,8 @@
|
|||
}
|
||||
},
|
||||
"required": [
|
||||
"c",
|
||||
"t"
|
||||
"t",
|
||||
"c"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -51,8 +51,8 @@
|
|||
}
|
||||
},
|
||||
"required": [
|
||||
"c",
|
||||
"t"
|
||||
"t",
|
||||
"c"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -69,8 +69,8 @@
|
|||
}
|
||||
},
|
||||
"required": [
|
||||
"c",
|
||||
"t"
|
||||
"t",
|
||||
"c"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -88,8 +88,8 @@
|
|||
}
|
||||
},
|
||||
"required": [
|
||||
"bar",
|
||||
"foo"
|
||||
"foo",
|
||||
"bar"
|
||||
]
|
||||
},
|
||||
"t": {
|
||||
|
@ -100,8 +100,8 @@
|
|||
}
|
||||
},
|
||||
"required": [
|
||||
"c",
|
||||
"t"
|
||||
"t",
|
||||
"c"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -129,8 +129,8 @@
|
|||
}
|
||||
},
|
||||
"required": [
|
||||
"c",
|
||||
"t"
|
||||
"t",
|
||||
"c"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -162,8 +162,8 @@
|
|||
}
|
||||
},
|
||||
"required": [
|
||||
"c",
|
||||
"t"
|
||||
"t",
|
||||
"c"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
@ -180,8 +180,8 @@
|
|||
}
|
||||
},
|
||||
"required": [
|
||||
"bar",
|
||||
"foo"
|
||||
"foo",
|
||||
"bar"
|
||||
]
|
||||
},
|
||||
"UnitStruct": {
|
||||
|
|
|
@ -64,8 +64,8 @@
|
|||
},
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"bar",
|
||||
"foo"
|
||||
"foo",
|
||||
"bar"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
@ -124,8 +124,8 @@
|
|||
}
|
||||
},
|
||||
"required": [
|
||||
"bar",
|
||||
"foo"
|
||||
"foo",
|
||||
"bar"
|
||||
]
|
||||
},
|
||||
"UnitStruct": {
|
||||
|
|
|
@ -63,8 +63,8 @@
|
|||
}
|
||||
},
|
||||
"required": [
|
||||
"bar",
|
||||
"foo"
|
||||
"foo",
|
||||
"bar"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
@ -123,8 +123,8 @@
|
|||
}
|
||||
},
|
||||
"required": [
|
||||
"bar",
|
||||
"foo"
|
||||
"foo",
|
||||
"bar"
|
||||
]
|
||||
},
|
||||
"UnitStruct": {
|
||||
|
|
|
@ -59,9 +59,9 @@
|
|||
}
|
||||
},
|
||||
"required": [
|
||||
"bar",
|
||||
"typeProperty",
|
||||
"foo",
|
||||
"typeProperty"
|
||||
"bar"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -81,9 +81,9 @@
|
|||
},
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"bar",
|
||||
"typeProperty",
|
||||
"foo",
|
||||
"typeProperty"
|
||||
"bar"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
|
@ -57,9 +57,9 @@
|
|||
}
|
||||
},
|
||||
"required": [
|
||||
"bar",
|
||||
"typeProperty",
|
||||
"foo",
|
||||
"typeProperty"
|
||||
"bar"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -78,9 +78,9 @@
|
|||
}
|
||||
},
|
||||
"required": [
|
||||
"bar",
|
||||
"typeProperty",
|
||||
"foo",
|
||||
"typeProperty"
|
||||
"bar"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
|
@ -30,8 +30,8 @@
|
|||
},
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"bar",
|
||||
"foo"
|
||||
"foo",
|
||||
"bar"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -66,8 +66,8 @@
|
|||
}
|
||||
},
|
||||
"required": [
|
||||
"bar",
|
||||
"foo"
|
||||
"foo",
|
||||
"bar"
|
||||
]
|
||||
},
|
||||
"UnitStruct": {
|
||||
|
|
|
@ -29,8 +29,8 @@
|
|||
}
|
||||
},
|
||||
"required": [
|
||||
"bar",
|
||||
"foo"
|
||||
"foo",
|
||||
"bar"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -65,8 +65,8 @@
|
|||
}
|
||||
},
|
||||
"required": [
|
||||
"bar",
|
||||
"foo"
|
||||
"foo",
|
||||
"bar"
|
||||
]
|
||||
},
|
||||
"UnitStruct": {
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
null
|
||||
],
|
||||
"required": [
|
||||
"bar",
|
||||
"foo"
|
||||
"foo",
|
||||
"bar"
|
||||
]
|
||||
}
|
|
@ -26,8 +26,8 @@
|
|||
}
|
||||
},
|
||||
"required": [
|
||||
"b",
|
||||
"f",
|
||||
"b",
|
||||
"s",
|
||||
"v"
|
||||
]
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
"replicas": {
|
||||
"type": "integer",
|
||||
"format": "uint32",
|
||||
"minimum": 0.0
|
||||
"minimum": 0
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
|
|
|
@ -10,11 +10,11 @@
|
|||
"x": {
|
||||
"type": "integer",
|
||||
"format": "uint8",
|
||||
"minimum": 0.0
|
||||
"minimum": 0
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"v",
|
||||
"x"
|
||||
"x",
|
||||
"v"
|
||||
]
|
||||
}
|
|
@ -13,7 +13,7 @@
|
|||
"nonzero_unsigned": {
|
||||
"type": "integer",
|
||||
"format": "uint32",
|
||||
"minimum": 1.0
|
||||
"minimum": 1
|
||||
},
|
||||
"signed": {
|
||||
"type": "integer",
|
||||
|
@ -22,13 +22,13 @@
|
|||
"unsigned": {
|
||||
"type": "integer",
|
||||
"format": "uint32",
|
||||
"minimum": 0.0
|
||||
"minimum": 0
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"nonzero_signed",
|
||||
"unsigned",
|
||||
"nonzero_unsigned",
|
||||
"signed",
|
||||
"unsigned"
|
||||
"nonzero_signed"
|
||||
]
|
||||
}
|
|
@ -11,8 +11,8 @@
|
|||
}
|
||||
},
|
||||
"required": [
|
||||
"borrowed",
|
||||
"owned"
|
||||
"owned",
|
||||
"borrowed"
|
||||
],
|
||||
"definitions": {
|
||||
"OsString": {
|
||||
|
@ -25,7 +25,7 @@
|
|||
"items": {
|
||||
"type": "integer",
|
||||
"format": "uint8",
|
||||
"minimum": 0.0
|
||||
"minimum": 0
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -41,7 +41,7 @@
|
|||
"items": {
|
||||
"type": "integer",
|
||||
"format": "uint16",
|
||||
"minimum": 0.0
|
||||
"minimum": 0
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
}
|
||||
},
|
||||
"required": [
|
||||
"bound",
|
||||
"range",
|
||||
"inclusive",
|
||||
"range"
|
||||
"bound"
|
||||
],
|
||||
"definitions": {
|
||||
"Bound_of_string": {
|
||||
|
@ -62,8 +62,8 @@
|
|||
}
|
||||
},
|
||||
"required": [
|
||||
"end",
|
||||
"start"
|
||||
"start",
|
||||
"end"
|
||||
]
|
||||
},
|
||||
"Range_of_uint": {
|
||||
|
@ -72,17 +72,17 @@
|
|||
"end": {
|
||||
"type": "integer",
|
||||
"format": "uint",
|
||||
"minimum": 0.0
|
||||
"minimum": 0
|
||||
},
|
||||
"start": {
|
||||
"type": "integer",
|
||||
"format": "uint",
|
||||
"minimum": 0.0
|
||||
"minimum": 0
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"end",
|
||||
"start"
|
||||
"start",
|
||||
"end"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,8 +47,8 @@
|
|||
}
|
||||
},
|
||||
"required": [
|
||||
"nanos",
|
||||
"secs"
|
||||
"secs",
|
||||
"nanos"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,9 +25,9 @@
|
|||
},
|
||||
"required": [
|
||||
"byte_or_bool2",
|
||||
"fake_map",
|
||||
"unit_or_t2",
|
||||
"s",
|
||||
"unit_or_t2"
|
||||
"fake_map"
|
||||
],
|
||||
"definitions": {
|
||||
"Or_for_null_and_int32": {
|
||||
|
@ -46,7 +46,7 @@
|
|||
{
|
||||
"type": "integer",
|
||||
"format": "uint8",
|
||||
"minimum": 0.0
|
||||
"minimum": 0
|
||||
},
|
||||
{
|
||||
"type": "boolean"
|
||||
|
|
|
@ -24,11 +24,11 @@
|
|||
}
|
||||
},
|
||||
"required": [
|
||||
"inner",
|
||||
"t",
|
||||
"u",
|
||||
"v",
|
||||
"w"
|
||||
"w",
|
||||
"inner"
|
||||
],
|
||||
"definitions": {
|
||||
"another-new-name": {
|
||||
|
|
|
@ -24,11 +24,11 @@
|
|||
}
|
||||
},
|
||||
"required": [
|
||||
"inner",
|
||||
"t",
|
||||
"u",
|
||||
"v",
|
||||
"w"
|
||||
"w",
|
||||
"inner"
|
||||
],
|
||||
"definitions": {
|
||||
"MySimpleStruct": {
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
}
|
||||
},
|
||||
"required": [
|
||||
"foo",
|
||||
"generic"
|
||||
"generic",
|
||||
"foo"
|
||||
],
|
||||
"definitions": {
|
||||
"MySimpleStruct": {
|
||||
|
@ -52,11 +52,11 @@
|
|||
}
|
||||
},
|
||||
"required": [
|
||||
"inner",
|
||||
"t",
|
||||
"u",
|
||||
"v",
|
||||
"w"
|
||||
"w",
|
||||
"inner"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,8 +29,8 @@
|
|||
},
|
||||
"required": [
|
||||
"int",
|
||||
"value",
|
||||
"values"
|
||||
"values",
|
||||
"value"
|
||||
],
|
||||
"definitions": {
|
||||
"Inner": {
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
},
|
||||
"required": [
|
||||
"int",
|
||||
"value",
|
||||
"values"
|
||||
"values",
|
||||
"value"
|
||||
],
|
||||
"definitions": {
|
||||
"Inner": {
|
||||
|
|
|
@ -29,8 +29,8 @@
|
|||
},
|
||||
"required": [
|
||||
"int",
|
||||
"value",
|
||||
"values"
|
||||
"values",
|
||||
"value"
|
||||
],
|
||||
"definitions": {
|
||||
"Inner": {
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
}
|
||||
},
|
||||
"required": [
|
||||
"c",
|
||||
"t"
|
||||
"t",
|
||||
"c"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -42,8 +42,8 @@
|
|||
}
|
||||
},
|
||||
"required": [
|
||||
"c",
|
||||
"t"
|
||||
"t",
|
||||
"c"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -71,8 +71,8 @@
|
|||
}
|
||||
},
|
||||
"required": [
|
||||
"c",
|
||||
"t"
|
||||
"t",
|
||||
"c"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -89,8 +89,8 @@
|
|||
}
|
||||
},
|
||||
"required": [
|
||||
"c",
|
||||
"t"
|
||||
"t",
|
||||
"c"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
}
|
||||
},
|
||||
"required": [
|
||||
"foo",
|
||||
"typeProperty"
|
||||
"typeProperty",
|
||||
"foo"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
}
|
||||
},
|
||||
"required": [
|
||||
"foo",
|
||||
"bar",
|
||||
"baz",
|
||||
"foo"
|
||||
"baz"
|
||||
]
|
||||
}
|
|
@ -18,7 +18,7 @@
|
|||
}
|
||||
},
|
||||
"required": [
|
||||
"included",
|
||||
"writable"
|
||||
"writable",
|
||||
"included"
|
||||
]
|
||||
}
|
|
@ -19,7 +19,7 @@
|
|||
},
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"bar",
|
||||
"foo"
|
||||
"foo",
|
||||
"bar"
|
||||
]
|
||||
}
|
|
@ -18,7 +18,7 @@
|
|||
}
|
||||
},
|
||||
"required": [
|
||||
"bar",
|
||||
"foo"
|
||||
"foo",
|
||||
"bar"
|
||||
]
|
||||
}
|
|
@ -31,14 +31,14 @@
|
|||
"min_max": {
|
||||
"type": "number",
|
||||
"format": "float",
|
||||
"maximum": 100.0,
|
||||
"maximum": 100,
|
||||
"minimum": 0.01
|
||||
},
|
||||
"min_max2": {
|
||||
"type": "number",
|
||||
"format": "float",
|
||||
"maximum": 1000.0,
|
||||
"minimum": 1.0
|
||||
"maximum": 1000,
|
||||
"minimum": 1
|
||||
},
|
||||
"non_empty_str": {
|
||||
"type": "string",
|
||||
|
@ -84,21 +84,21 @@
|
|||
}
|
||||
},
|
||||
"required": [
|
||||
"contains_str1",
|
||||
"contains_str2",
|
||||
"email_address",
|
||||
"homepage",
|
||||
"map_contains",
|
||||
"min_max",
|
||||
"min_max2",
|
||||
"non_empty_str",
|
||||
"non_empty_str2",
|
||||
"pair",
|
||||
"regex_str1",
|
||||
"regex_str2",
|
||||
"regex_str3",
|
||||
"required_option",
|
||||
"contains_str1",
|
||||
"contains_str2",
|
||||
"email_address",
|
||||
"tel",
|
||||
"homepage",
|
||||
"non_empty_str",
|
||||
"non_empty_str2",
|
||||
"pair",
|
||||
"map_contains",
|
||||
"required_option",
|
||||
"x"
|
||||
]
|
||||
}
|
|
@ -25,8 +25,8 @@
|
|||
"items": {
|
||||
"type": "integer",
|
||||
"format": "int32",
|
||||
"maximum": 10.0,
|
||||
"minimum": -10.0
|
||||
"maximum": 10,
|
||||
"minimum": -10
|
||||
}
|
||||
},
|
||||
"vec_str_length": {
|
||||
|
@ -65,10 +65,10 @@
|
|||
"required": [
|
||||
"array_str_length",
|
||||
"slice_str_contains",
|
||||
"vec_i32_range",
|
||||
"vec_str_regex",
|
||||
"vec_str_length",
|
||||
"vec_str_length2",
|
||||
"vec_str_regex",
|
||||
"vec_str_url"
|
||||
"vec_str_url",
|
||||
"vec_i32_range"
|
||||
]
|
||||
}
|
|
@ -3,6 +3,6 @@
|
|||
"title": "NewType",
|
||||
"type": "integer",
|
||||
"format": "uint8",
|
||||
"maximum": 10.0,
|
||||
"minimum": 0.0
|
||||
"maximum": 10,
|
||||
"minimum": 0
|
||||
}
|
|
@ -31,14 +31,14 @@
|
|||
"min_max": {
|
||||
"type": "number",
|
||||
"format": "float",
|
||||
"maximum": 100.0,
|
||||
"maximum": 100,
|
||||
"minimum": 0.01
|
||||
},
|
||||
"min_max2": {
|
||||
"type": "number",
|
||||
"format": "float",
|
||||
"maximum": 1000.0,
|
||||
"minimum": 1.0
|
||||
"maximum": 1000,
|
||||
"minimum": 1
|
||||
},
|
||||
"non_empty_str": {
|
||||
"type": "string",
|
||||
|
@ -84,21 +84,21 @@
|
|||
}
|
||||
},
|
||||
"required": [
|
||||
"contains_str1",
|
||||
"contains_str2",
|
||||
"email_address",
|
||||
"homepage",
|
||||
"map_contains",
|
||||
"min_max",
|
||||
"min_max2",
|
||||
"non_empty_str",
|
||||
"non_empty_str2",
|
||||
"pair",
|
||||
"regex_str1",
|
||||
"regex_str2",
|
||||
"regex_str3",
|
||||
"required_option",
|
||||
"contains_str1",
|
||||
"contains_str2",
|
||||
"email_address",
|
||||
"tel",
|
||||
"homepage",
|
||||
"non_empty_str",
|
||||
"non_empty_str2",
|
||||
"pair",
|
||||
"map_contains",
|
||||
"required_option",
|
||||
"x"
|
||||
]
|
||||
}
|
|
@ -6,8 +6,8 @@
|
|||
{
|
||||
"type": "integer",
|
||||
"format": "uint8",
|
||||
"maximum": 10.0,
|
||||
"minimum": 0.0
|
||||
"maximum": 10,
|
||||
"minimum": 0
|
||||
},
|
||||
{
|
||||
"type": "boolean"
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
use pretty_assertions::assert_eq;
|
||||
use schemars::visit::Visitor;
|
||||
use schemars::{gen::SchemaSettings, schema_for, JsonSchema, Schema};
|
||||
use std::error::Error;
|
||||
use std::fs;
|
||||
|
@ -19,15 +18,6 @@ pub fn test_default_generated_schema<T: JsonSchema>(file: &str) -> TestResult {
|
|||
}
|
||||
|
||||
pub fn test_schema(actual: &Schema, file: &str) -> TestResult {
|
||||
// TEMP for easier comparison of schemas handling changes that don't actually affect a schema:
|
||||
// - `required` ordering has changed
|
||||
// - previously `f64` properties may now be integers
|
||||
let actual = &{
|
||||
let mut actual = actual.clone();
|
||||
TempFixupForTests.visit_schema(&mut actual);
|
||||
actual
|
||||
};
|
||||
|
||||
let expected_json = match fs::read_to_string(format!("tests/expected/{}.json", file)) {
|
||||
Ok(j) => j,
|
||||
Err(e) => {
|
||||
|
@ -50,25 +40,3 @@ fn write_actual_to_file(schema: &Schema, file: &str) -> TestResult {
|
|||
fs::write(format!("tests/actual/{}.json", file), actual_json)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
struct TempFixupForTests;
|
||||
|
||||
impl schemars::visit::Visitor for TempFixupForTests {
|
||||
fn visit_schema(&mut self, schema: &mut Schema) {
|
||||
schemars::visit::visit_schema(self, schema);
|
||||
|
||||
if let Some(object) = schema.as_object_mut() {
|
||||
if let Some(serde_json::Value::Array(required)) = object.get_mut("required") {
|
||||
required.sort_unstable_by(|a, b| a.as_str().cmp(&b.as_str()));
|
||||
}
|
||||
|
||||
for (key, value) in object {
|
||||
if key == "multipleOf" || key.ends_with("aximum") || key.ends_with("inimum") {
|
||||
if let Some(f) = value.as_f64() {
|
||||
*value = f.into();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue