Skip to main content

list_properties

Function list_properties 

Source
pub fn list_properties(schema: &Value) -> Vec<PropertyInfo>
Expand description

Extract property information from a JSON Schema object, sorted by name.

Works with both schemars::Schema (via as_value()) and raw serde_json::Value.

use vld::prelude::*;

vld::schema! {
    #[derive(Debug)]
    pub struct UserSchema {
        pub name: String => vld::string().min(1),
        pub age: i64 => vld::number().int().min(0),
    }
}

let json = UserSchema::json_schema();
let props = vld_openapi::validator::list_properties(&json);
assert_eq!(props.len(), 2);