Skip to content

Commit db2288b

Browse files
committed
Remove the nullable transform from the policies schemas
1 parent 3d3412a commit db2288b

File tree

5 files changed

+47
-33
lines changed

5 files changed

+47
-33
lines changed

crates/policy/src/bin/schema.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@ use std::path::{Path, PathBuf};
1414
use mas_policy::model::{
1515
AuthorizationGrantInput, ClientRegistrationInput, EmailInput, RegisterInput,
1616
};
17-
use schemars::{
18-
JsonSchema,
19-
generate::SchemaSettings,
20-
transform::{AddNullable, RecursiveTransform},
21-
};
17+
use schemars::{JsonSchema, generate::SchemaSettings};
2218

2319
fn write_schema<T: JsonSchema>(out_dir: Option<&Path>, file: &str) {
2420
let mut writer: Box<dyn std::io::Write> = if let Some(out_dir) = out_dir {
@@ -31,9 +27,7 @@ fn write_schema<T: JsonSchema>(out_dir: Option<&Path>, file: &str) {
3127
Box::new(std::io::stdout())
3228
};
3329

34-
let generator = SchemaSettings::draft07()
35-
.with_transform(RecursiveTransform(AddNullable::default()))
36-
.into_generator();
30+
let generator = SchemaSettings::draft07().into_generator();
3731
let schema = generator.into_root_schema_for::<T>();
3832
serde_json::to_writer_pretty(&mut writer, &schema).expect("Failed to serialize schema");
3933
writer.flush().expect("Failed to flush writer");

policies/schema/authorization_grant_input.json

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
"type": "object",
66
"properties": {
77
"user": {
8-
"type": "object",
9-
"additionalProperties": true,
10-
"nullable": true
8+
"type": [
9+
"object",
10+
"null"
11+
],
12+
"additionalProperties": true
1113
},
1214
"client": {
1315
"type": "object",
@@ -44,14 +46,18 @@
4446
"properties": {
4547
"ip_address": {
4648
"description": "IP address of the entity making the request",
47-
"type": "string",
48-
"format": "ip",
49-
"nullable": true
49+
"type": [
50+
"string",
51+
"null"
52+
],
53+
"format": "ip"
5054
},
5155
"user_agent": {
5256
"description": "User agent of the entity making the request",
53-
"type": "string",
54-
"nullable": true
57+
"type": [
58+
"string",
59+
"null"
60+
]
5561
}
5662
}
5763
}

policies/schema/client_registration_input.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,18 @@
2323
"properties": {
2424
"ip_address": {
2525
"description": "IP address of the entity making the request",
26-
"type": "string",
27-
"format": "ip",
28-
"nullable": true
26+
"type": [
27+
"string",
28+
"null"
29+
],
30+
"format": "ip"
2931
},
3032
"user_agent": {
3133
"description": "User agent of the entity making the request",
32-
"type": "string",
33-
"nullable": true
34+
"type": [
35+
"string",
36+
"null"
37+
]
3438
}
3539
}
3640
}

policies/schema/email_input.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,18 @@
2222
"properties": {
2323
"ip_address": {
2424
"description": "IP address of the entity making the request",
25-
"type": "string",
26-
"format": "ip",
27-
"nullable": true
25+
"type": [
26+
"string",
27+
"null"
28+
],
29+
"format": "ip"
2830
},
2931
"user_agent": {
3032
"description": "User agent of the entity making the request",
31-
"type": "string",
32-
"nullable": true
33+
"type": [
34+
"string",
35+
"null"
36+
]
3337
}
3438
}
3539
}

policies/schema/register_input.json

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
"type": "string"
1212
},
1313
"email": {
14-
"type": "string",
15-
"nullable": true
14+
"type": [
15+
"string",
16+
"null"
17+
]
1618
},
1719
"requester": {
1820
"$ref": "#/definitions/Requester"
@@ -37,14 +39,18 @@
3739
"properties": {
3840
"ip_address": {
3941
"description": "IP address of the entity making the request",
40-
"type": "string",
41-
"format": "ip",
42-
"nullable": true
42+
"type": [
43+
"string",
44+
"null"
45+
],
46+
"format": "ip"
4347
},
4448
"user_agent": {
4549
"description": "User agent of the entity making the request",
46-
"type": "string",
47-
"nullable": true
50+
"type": [
51+
"string",
52+
"null"
53+
]
4854
}
4955
}
5056
}

0 commit comments

Comments
 (0)