Macro json_schema

Source
macro_rules! json_schema {
    (
        {$($json_object:tt)*}
    ) => { ... };
    (true) => { ... };
    (false) => { ... };
}
Expand description

Construct a Schema from a JSON literal. This can either be a JSON object, or a boolean (true or false).

You can interpolate variables or expressions into a JSON object using the same rules as the serde_json::json macro.

ยงExample

use schemars::{Schema, json_schema};

let desc = "A helpful description.";
let my_schema: Schema = json_schema!({
    "description": desc,
    "type": ["object", "null"]
});