Skip to main content

strip_null_from_enum

Function strip_null_from_enum 

Source
pub fn strip_null_from_enum(schema: &mut Value)
Expand description

Removes JSON null values from enum arrays in the schema and all nested sub-schemas.

If removing null results in an empty enum array, the enum keyword is removed entirely.

ยงExample

use serde_json::json;
use adk_core::schema_utils::strip_null_from_enum;

let mut schema = json!({
    "type": "string",
    "enum": ["a", null, "b"]
});

strip_null_from_enum(&mut schema);
assert_eq!(schema["enum"], json!(["a", "b"]));