define schema breakage violations

This commit is contained in:
Adam Perry
2026-06-25 14:43:42 +00:00
parent bf8f6e7452
commit 6a7e286383
4 changed files with 31 additions and 0 deletions
+1
View File
@@ -3844,6 +3844,7 @@ version = "0.0.0"
dependencies = [
"anyhow",
"pretty_assertions",
"serde",
"serde_json",
]
+1
View File
@@ -14,6 +14,7 @@ workspace = true
[dependencies]
anyhow = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
[dev-dependencies]
+3
View File
@@ -1,5 +1,6 @@
mod model;
mod parse;
mod violation;
pub use model::ApiSchema;
pub(crate) use model::Arguments;
@@ -14,3 +15,5 @@ pub(crate) use model::TypeSet;
pub(crate) use model::UnionKind;
pub(crate) use model::UnionSchema;
pub(crate) use model::ValueSet;
pub use violation::SchemaBreakage;
pub use violation::ViolationKind;
@@ -0,0 +1,26 @@
use serde::Deserialize;
use serde::Serialize;
use serde_json::Value;
#[derive(Clone, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)]
#[serde(rename_all = "camelCase")]
pub enum ViolationKind {
AdditionalPropertiesNarrowed,
ConstraintChanged,
EnumNarrowed,
MethodRemoved,
PropertyRemoved,
RequiredPropertyAdded,
TypeNarrowed,
UnionVariantRemoved,
}
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct SchemaBreakage {
pub kind: ViolationKind,
pub method: String,
pub path: String,
pub before: Value,
pub after: Value,
}