Skip to content

Commit 8c2c32b

Browse files
committed
Regenerate example schemas
1 parent f5d2142 commit 8c2c32b

19 files changed

+244
-242
lines changed

docs/_includes/examples/custom_serialization.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use schemars::schema::{Schema, SchemaObject};
1+
use schemars::Schema;
22
use schemars::{gen::SchemaGenerator, schema_for, JsonSchema};
33
use serde::{Deserialize, Serialize};
44

@@ -21,9 +21,11 @@ pub struct MyStruct {
2121
}
2222

2323
fn make_custom_schema(gen: &mut SchemaGenerator) -> Schema {
24-
let mut schema: SchemaObject = <String>::json_schema(gen).into();
25-
schema.format = Some("boolean".to_owned());
26-
schema.into()
24+
let mut schema = String::json_schema(gen);
25+
schema
26+
.ensure_object()
27+
.insert("format".into(), "boolean".into());
28+
schema
2729
}
2830

2931
fn eight() -> i32 {

docs/_includes/examples/custom_serialization.schema.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@
44
"type": "object",
55
"properties": {
66
"bool_as_string": {
7-
"default": "false",
87
"type": "string",
9-
"format": "boolean"
8+
"format": "boolean",
9+
"default": "false"
1010
},
1111
"bool_normal": {
12-
"default": false,
13-
"type": "boolean"
12+
"type": "boolean",
13+
"default": false
1414
},
1515
"int_as_string": {
16-
"default": "8",
17-
"type": "string"
16+
"type": "string",
17+
"default": "8"
1818
},
1919
"int_normal": {
20-
"default": 8,
2120
"type": "integer",
22-
"format": "int32"
21+
"format": "int32",
22+
"default": 8
2323
}
2424
}
2525
}

docs/_includes/examples/custom_settings.schema.json

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
"$schema": "http://json-schema.org/draft-07/schema#",
33
"title": "MyStruct",
44
"type": "object",
5-
"required": [
6-
"my_bool",
7-
"my_int"
8-
],
95
"properties": {
106
"my_bool": {
117
"type": "boolean"
@@ -23,32 +19,30 @@
2319
"nullable": true
2420
}
2521
},
22+
"required": [
23+
"my_int",
24+
"my_bool"
25+
],
2626
"definitions": {
2727
"MyEnum": {
2828
"oneOf": [
2929
{
3030
"type": "object",
31-
"required": [
32-
"StringNewType"
33-
],
3431
"properties": {
3532
"StringNewType": {
3633
"type": "string"
3734
}
3835
},
39-
"additionalProperties": false
36+
"additionalProperties": false,
37+
"required": [
38+
"StringNewType"
39+
]
4040
},
4141
{
4242
"type": "object",
43-
"required": [
44-
"StructVariant"
45-
],
4643
"properties": {
4744
"StructVariant": {
4845
"type": "object",
49-
"required": [
50-
"floats"
51-
],
5246
"properties": {
5347
"floats": {
5448
"type": "array",
@@ -57,10 +51,16 @@
5751
"format": "float"
5852
}
5953
}
60-
}
54+
},
55+
"required": [
56+
"floats"
57+
]
6158
}
6259
},
63-
"additionalProperties": false
60+
"additionalProperties": false,
61+
"required": [
62+
"StructVariant"
63+
]
6464
}
6565
]
6666
}

docs/_includes/examples/doc_comments.schema.json

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
"title": "My Amazing Struct",
44
"description": "This struct shows off generating a schema with a custom title and description.",
55
"type": "object",
6-
"required": [
7-
"my_bool",
8-
"my_int"
9-
],
106
"properties": {
117
"my_bool": {
128
"description": "This bool has a description, but no title.",
@@ -30,35 +26,33 @@
3026
]
3127
}
3228
},
29+
"required": [
30+
"my_int",
31+
"my_bool"
32+
],
3333
"definitions": {
3434
"MyEnum": {
3535
"title": "My Amazing Enum",
3636
"oneOf": [
3737
{
3838
"description": "A wrapper around a `String`",
3939
"type": "object",
40-
"required": [
41-
"StringNewType"
42-
],
4340
"properties": {
4441
"StringNewType": {
4542
"type": "string"
4643
}
4744
},
48-
"additionalProperties": false
45+
"additionalProperties": false,
46+
"required": [
47+
"StringNewType"
48+
]
4949
},
5050
{
5151
"description": "A struct-like enum variant which contains some floats",
5252
"type": "object",
53-
"required": [
54-
"StructVariant"
55-
],
5653
"properties": {
5754
"StructVariant": {
5855
"type": "object",
59-
"required": [
60-
"floats"
61-
],
6256
"properties": {
6357
"floats": {
6458
"description": "The floats themselves",
@@ -68,10 +62,16 @@
6862
"format": "float"
6963
}
7064
}
71-
}
65+
},
66+
"required": [
67+
"floats"
68+
]
7269
}
7370
},
74-
"additionalProperties": false
71+
"additionalProperties": false,
72+
"required": [
73+
"StructVariant"
74+
]
7575
}
7676
]
7777
}
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
11
{
22
"$schema": "http://json-schema.org/draft-07/schema#",
33
"title": "MyStruct",
4-
"examples": [
5-
{
6-
"my_bool": true,
7-
"my_int": 123,
8-
"my_nullable_enum": {
9-
"StringNewType": "foo"
10-
}
11-
}
12-
],
134
"type": "object",
145
"properties": {
156
"my_bool": {
@@ -19,5 +10,14 @@
1910
"type": "integer"
2011
},
2112
"my_nullable_enum": true
22-
}
13+
},
14+
"examples": [
15+
{
16+
"my_bool": true,
17+
"my_int": 123,
18+
"my_nullable_enum": {
19+
"StringNewType": "foo"
20+
}
21+
}
22+
]
2323
}

docs/_includes/examples/main.schema.json

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
"$schema": "http://json-schema.org/draft-07/schema#",
33
"title": "MyStruct",
44
"type": "object",
5-
"required": [
6-
"my_bool",
7-
"my_int"
8-
],
95
"properties": {
106
"my_bool": {
117
"type": "boolean"
@@ -25,32 +21,30 @@
2521
]
2622
}
2723
},
24+
"required": [
25+
"my_int",
26+
"my_bool"
27+
],
2828
"definitions": {
2929
"MyEnum": {
3030
"oneOf": [
3131
{
3232
"type": "object",
33-
"required": [
34-
"StringNewType"
35-
],
3633
"properties": {
3734
"StringNewType": {
3835
"type": "string"
3936
}
4037
},
41-
"additionalProperties": false
38+
"additionalProperties": false,
39+
"required": [
40+
"StringNewType"
41+
]
4242
},
4343
{
4444
"type": "object",
45-
"required": [
46-
"StructVariant"
47-
],
4845
"properties": {
4946
"StructVariant": {
5047
"type": "object",
51-
"required": [
52-
"floats"
53-
],
5448
"properties": {
5549
"floats": {
5650
"type": "array",
@@ -59,10 +53,16 @@
5953
"format": "float"
6054
}
6155
}
62-
}
56+
},
57+
"required": [
58+
"floats"
59+
]
6360
}
6461
},
65-
"additionalProperties": false
62+
"additionalProperties": false,
63+
"required": [
64+
"StructVariant"
65+
]
6666
}
6767
]
6868
}

docs/_includes/examples/remote_derive.schema.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22
"$schema": "http://json-schema.org/draft-07/schema#",
33
"title": "Process",
44
"type": "object",
5-
"required": [
6-
"command_line",
7-
"durations",
8-
"wall_time"
9-
],
105
"properties": {
116
"command_line": {
127
"type": "string"
@@ -21,13 +16,14 @@
2116
"$ref": "#/definitions/Duration"
2217
}
2318
},
19+
"required": [
20+
"command_line",
21+
"wall_time",
22+
"durations"
23+
],
2424
"definitions": {
2525
"Duration": {
2626
"type": "object",
27-
"required": [
28-
"nanos",
29-
"secs"
30-
],
3127
"properties": {
3228
"nanos": {
3329
"type": "integer",
@@ -37,7 +33,11 @@
3733
"type": "integer",
3834
"format": "int64"
3935
}
40-
}
36+
},
37+
"required": [
38+
"secs",
39+
"nanos"
40+
]
4141
}
4242
}
4343
}

0 commit comments

Comments
 (0)