greentic-flow-builder 0.4.0

Greentic Flow Builder — orchestrator that powers Adaptive Card design via the adaptive-card-mcp toolkit
Documentation
//! `POST /api/validate` — passthrough to `adaptive_card_core::validate_card`.

use adaptive_card_core::{Host, validate_card};
use axum::Json;
use axum::http::StatusCode;
use axum::response::IntoResponse;
use serde::Deserialize;
use serde_json::Value;

#[derive(Deserialize)]
pub struct ValidateBody {
    pub card: Value,
    #[serde(default)]
    pub host: Option<String>,
}

pub async fn post_validate(Json(body): Json<ValidateBody>) -> impl IntoResponse {
    let host = body.host.as_deref().and_then(Host::from_str);
    let report = validate_card(&body.card, host);
    let value = serde_json::to_value(report).unwrap_or_default();
    (StatusCode::OK, Json(value)).into_response()
}

#[cfg(test)]
mod tests {
    use super::*;
    use serde_json::json;

    #[tokio::test]
    async fn validates_simple_teams_card() {
        let body = ValidateBody {
            card: json!({
                "type": "AdaptiveCard",
                "version": "1.6",
                "speak": "Hi",
                "body": [{"type": "TextBlock", "text": "Hello", "wrap": true}]
            }),
            host: Some("teams".into()),
        };
        let resp = post_validate(Json(body)).await.into_response();
        assert_eq!(resp.status(), StatusCode::OK);
    }
}