Compare commits

..

3 commits

Author SHA1 Message Date
de9566709a feat: support hashbrown015 2025-02-15 23:02:32 +03:00
0b5abbcd0f add support for compact_str crate 2025-02-15 23:02:15 +03:00
Graham Esau
efb74969e2
Update dependencies (#368) 2025-01-24 22:03:59 +00:00
5 changed files with 21 additions and 1398 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 }}

1388
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -39,12 +39,11 @@ compact_str08 = { version = "0.8", default-features = false, optional = true, pa
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 }
hashbrown015 = { version = "0.15", default-features = false, features = ["serde"], package = "hashbrown" }

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);
}