Update dependencies (#368)

This commit is contained in:
Graham Esau 2025-01-24 22:03:59 +00:00 committed by GitHub
parent f8c1fe21b7
commit efb74969e2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 453 additions and 397 deletions

View file

@ -24,6 +24,14 @@ jobs:
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Downgrade packages for MSRV
if: matrix.rust == '1.70.0'
run: |
cargo add --dev jsonschema@0.20
cargo add --dev garde --git https://github.com/jprochazk/garde.git --rev be00ddddf8de14530ee890ccfdbaf0b13fb32852
cargo add --dev validator@0.18.1
cargo update url --precise 2.5.2
working-directory: ./schemars
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}

819
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -37,12 +37,11 @@ uuid1 = { version = "1.0", default-features = false, optional = true, package =
pretty_assertions = "1.2.1"
trybuild = "1.0"
serde = { version = "1.0", features = ["derive"] }
jsonschema = { version = "0.20", default-features = false }
jsonschema = { version = "0.28", default-features = false }
snapbox = { version = "0.6.17", features = ["json"] }
serde_repr = "0.1.19"
# Use github source until published garde version supports `length(equal = ...)` attr
garde = { git = "https://github.com/jprochazk/garde.git", rev = "be00ddddf8de14530ee890ccfdbaf0b13fb32852", features = ["derive", "email", "regex", "url"] }
validator = { version = "0.18.1", features = ["derive"] }
garde = { version = "0.22", features = ["derive", "email", "regex", "url"] }
validator = { version = "0.20", features = ["derive"] }
regex = { version = "1.10.6", default-features = false }
arrayvec07 = { version = "0.7", default-features = false, features = ["serde"], package = "arrayvec"}

View file

@ -60,8 +60,12 @@ fn custom_struct() {
fn custom_struct_openapi3() {
let value = struct_value();
test!(value: value.clone(), SchemaSettings::openapi3())
.assert_snapshot()
test!(value: value.clone(), SchemaSettings::openapi3()).assert_snapshot();
// schemars uses a nonstandard meta-schema for openapi 3.0 which the jsonschema crate doesn't
// accept, so we swap it out for the standard draft-04 meta-schema.
let draft04 = "http://json-schema.org/draft-04/schema".to_owned();
test!(value: value.clone(), SchemaSettings::openapi3().with(|o| o.meta_schema = Some(draft04)))
.assert_allows_ser_roundtrip([value, MyStruct::default()]);
}

View file

@ -5,7 +5,7 @@ use schemars::{
};
use serde::{de::DeserializeOwned, Serialize};
use serde_json::{json, Value};
use snapbox::IntoJson;
use snapbox::{data::DataFormat, IntoJson};
use std::{
any::type_name, borrow::Borrow, cell::OnceCell, f64, marker::PhantomData, path::Path,
sync::OnceLock,
@ -74,18 +74,18 @@ impl<T: JsonSchema> TestHelper<T> {
if self.de_schema == self.ser_schema {
snapbox::assert_data_eq!(
(&self.de_schema).into_json(),
snapbox::Data::read_from(Path::new(&common_path), None).raw()
snapbox::Data::read_from(Path::new(&common_path), Some(DataFormat::Json)).raw()
);
_ = std::fs::remove_file(de_path);
_ = std::fs::remove_file(ser_path);
} else {
snapbox::assert_data_eq!(
(&self.de_schema).into_json(),
snapbox::Data::read_from(Path::new(&de_path), None).raw()
snapbox::Data::read_from(Path::new(&de_path), Some(DataFormat::Json)).raw()
);
snapbox::assert_data_eq!(
(&self.ser_schema).into_json(),
snapbox::Data::read_from(Path::new(&ser_path), None).raw()
snapbox::Data::read_from(Path::new(&ser_path), Some(DataFormat::Json)).raw()
);
_ = std::fs::remove_file(common_path);
}