Skip to main content

input_schema_for

Function input_schema_for 

Source
pub fn input_schema_for<T: JsonSchema>() -> Value
Expand description

Generate a JSON Schema Value from a type that derives JsonSchema.

Use this in WorkflowHandler::input_schema to automatically derive the schema from your input struct instead of writing JSON by hand.

ยงExamples

use schemars::JsonSchema;
use serde::Deserialize;
use ironflow_engine::handler::input_schema_for;

#[derive(Deserialize, JsonSchema)]
struct DeployInput {
    environment: String,
    dry_run: Option<bool>,
}

let schema = input_schema_for::<DeployInput>();
assert_eq!(schema["type"], "object");
assert!(schema["properties"]["environment"].is_object());