Skip to content

Commit 131ff77

Browse files
committed
wip
0 parents  commit 131ff77

File tree

4 files changed

+742
-0
lines changed

4 files changed

+742
-0
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/target
2+
3+
4+
# Added by cargo
5+
#
6+
# already existing elements were commented out
7+
8+
#/target
9+
/Cargo.lock

Cargo.toml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[package]
2+
name = "json-schema-diff"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[lib]
7+
name = "json_schema_diff"
8+
path = "src/lib.rs"
9+
10+
[[bin]]
11+
required-features = ["build-binary"]
12+
name = "json-schema-diff"
13+
path = "src/bin/main.rs"
14+
15+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
16+
17+
[dependencies]
18+
anyhow = { version = "1.0.70", optional = true }
19+
clap = { version = "4.1.13", features = ["std", "derive"], default_features = false, optional = true }
20+
jsonref = "0.4.0"
21+
serde = "1.0.158"
22+
serde_json = "1.0.94"
23+
thiserror = "1.0.40"
24+
25+
[features]
26+
build-binary = ["clap", "anyhow"]
27+
28+
[dev-dependencies]
29+
insta = "1.29.0"

src/bin/main.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
use clap::Parser;
2+
use std::fs::File;
3+
use std::path::PathBuf;
4+
5+
6+
use anyhow::Error;
7+
8+
/// Compare old and new schema, and print differences
9+
#[derive(Parser)]
10+
#[clap(about, version)]
11+
struct Args {
12+
/// The old schema
13+
lhs: PathBuf,
14+
/// The new schema
15+
rhs: PathBuf,
16+
}
17+
18+
fn main() -> Result<(), Error> {
19+
let args = Args::parse();
20+
21+
let lhs: serde_json::Value = serde_json::from_reader(File::open(args.lhs)?)?;
22+
let rhs: serde_json::Value = serde_json::from_reader(File::open(args.rhs)?)?;
23+
24+
let changes = json_schema_diff::diff(lhs, rhs)?;
25+
26+
for change in changes {
27+
println!("{:?}", change);
28+
}
29+
Ok(())
30+
}

0 commit comments

Comments
 (0)