use std::sync::Arc;
use schemars::JsonSchema;
use serde_json::Value;
use crate::error::AdapterError;
pub fn parse_input<T: for<'de> serde::Deserialize<'de>>(input: Value) -> Result<T, AdapterError> {
serde_json::from_value::<T>(input).map_err(|err| AdapterError::Validation {
field: "arguments".to_string(),
message: err.to_string(),
})
}
#[must_use]
pub fn schema_for<T: JsonSchema>() -> Arc<serde_json::Map<String, Value>> {
let schema = schemars::schema_for!(T);
let json = serde_json::to_value(schema).expect("schema must be a JSON object");
let map = json
.as_object()
.expect("schemars schema_for! always produces an object")
.clone();
Arc::new(map)
}