Remove the nullable transform from the policies schemas

This commit is contained in:
Quentin Gliech
2025-11-07 11:11:41 +01:00
parent d0a5a1406b
commit 7d2f85c891
5 changed files with 47 additions and 33 deletions

View File

@@ -14,11 +14,7 @@ use std::path::{Path, PathBuf};
use mas_policy::model::{
AuthorizationGrantInput, ClientRegistrationInput, EmailInput, RegisterInput,
};
use schemars::{
JsonSchema,
generate::SchemaSettings,
transform::{AddNullable, RecursiveTransform},
};
use schemars::{JsonSchema, generate::SchemaSettings};
fn write_schema<T: JsonSchema>(out_dir: Option<&Path>, file: &str) {
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) {
Box::new(std::io::stdout())
};
let generator = SchemaSettings::draft07()
.with_transform(RecursiveTransform(AddNullable::default()))
.into_generator();
let generator = SchemaSettings::draft07().into_generator();
let schema = generator.into_root_schema_for::<T>();
serde_json::to_writer_pretty(&mut writer, &schema).expect("Failed to serialize schema");
writer.flush().expect("Failed to flush writer");

View File

@@ -5,9 +5,11 @@
"type": "object",
"properties": {
"user": {
"type": "object",
"additionalProperties": true,
"nullable": true
"type": [
"object",
"null"
],
"additionalProperties": true
},
"client": {
"type": "object",
@@ -44,14 +46,18 @@
"properties": {
"ip_address": {
"description": "IP address of the entity making the request",
"type": "string",
"format": "ip",
"nullable": true
"type": [
"string",
"null"
],
"format": "ip"
},
"user_agent": {
"description": "User agent of the entity making the request",
"type": "string",
"nullable": true
"type": [
"string",
"null"
]
}
}
}

View File

@@ -23,14 +23,18 @@
"properties": {
"ip_address": {
"description": "IP address of the entity making the request",
"type": "string",
"format": "ip",
"nullable": true
"type": [
"string",
"null"
],
"format": "ip"
},
"user_agent": {
"description": "User agent of the entity making the request",
"type": "string",
"nullable": true
"type": [
"string",
"null"
]
}
}
}

View File

@@ -22,14 +22,18 @@
"properties": {
"ip_address": {
"description": "IP address of the entity making the request",
"type": "string",
"format": "ip",
"nullable": true
"type": [
"string",
"null"
],
"format": "ip"
},
"user_agent": {
"description": "User agent of the entity making the request",
"type": "string",
"nullable": true
"type": [
"string",
"null"
]
}
}
}

View File

@@ -11,8 +11,10 @@
"type": "string"
},
"email": {
"type": "string",
"nullable": true
"type": [
"string",
"null"
]
},
"requester": {
"$ref": "#/definitions/Requester"
@@ -37,14 +39,18 @@
"properties": {
"ip_address": {
"description": "IP address of the entity making the request",
"type": "string",
"format": "ip",
"nullable": true
"type": [
"string",
"null"
],
"format": "ip"
},
"user_agent": {
"description": "User agent of the entity making the request",
"type": "string",
"nullable": true
"type": [
"string",
"null"
]
}
}
}