use serde::Serialize;
#[derive(Clone, Debug, PartialEq, Serialize)]
pub struct Diagnostic {
pub source: String,
pub code: String,
pub severity: String,
pub path: Vec<serde_json::Value>,
pub message: String,
}
impl Diagnostic {
pub fn error(source: &str, code: &str, message: impl Into<String>) -> Self {
Self {
source: source.to_string(),
code: code.to_string(),
severity: "error".to_string(),
path: vec![],
message: message.into(),
}
}
pub fn at(mut self, path: Vec<serde_json::Value>) -> Self {
self.path = path;
self
}
}
pub type Diagnostics = Vec<Diagnostic>;