From 7d2f85c89162576aa2adc5c8ad28ce830a9e53ab Mon Sep 17 00:00:00 2001 From: Quentin Gliech Date: Fri, 7 Nov 2025 11:11:41 +0100 Subject: [PATCH] Remove the nullable transform from the policies schemas --- crates/policy/src/bin/schema.rs | 10 ++------- .../schema/authorization_grant_input.json | 22 ++++++++++++------- .../schema/client_registration_input.json | 14 +++++++----- policies/schema/email_input.json | 14 +++++++----- policies/schema/register_input.json | 20 +++++++++++------ 5 files changed, 47 insertions(+), 33 deletions(-) diff --git a/crates/policy/src/bin/schema.rs b/crates/policy/src/bin/schema.rs index 0e4ca9d87..8e9c81a07 100644 --- a/crates/policy/src/bin/schema.rs +++ b/crates/policy/src/bin/schema.rs @@ -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(out_dir: Option<&Path>, file: &str) { let mut writer: Box = if let Some(out_dir) = out_dir { @@ -31,9 +27,7 @@ fn write_schema(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::(); serde_json::to_writer_pretty(&mut writer, &schema).expect("Failed to serialize schema"); writer.flush().expect("Failed to flush writer"); diff --git a/policies/schema/authorization_grant_input.json b/policies/schema/authorization_grant_input.json index 501c46b92..f3635f45a 100644 --- a/policies/schema/authorization_grant_input.json +++ b/policies/schema/authorization_grant_input.json @@ -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" + ] } } } diff --git a/policies/schema/client_registration_input.json b/policies/schema/client_registration_input.json index d4ffe366f..ca9da8440 100644 --- a/policies/schema/client_registration_input.json +++ b/policies/schema/client_registration_input.json @@ -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" + ] } } } diff --git a/policies/schema/email_input.json b/policies/schema/email_input.json index df6bd91fc..f807fbc0e 100644 --- a/policies/schema/email_input.json +++ b/policies/schema/email_input.json @@ -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" + ] } } } diff --git a/policies/schema/register_input.json b/policies/schema/register_input.json index 17b7c2f0a..ce794d064 100644 --- a/policies/schema/register_input.json +++ b/policies/schema/register_input.json @@ -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" + ] } } }