From 10bc661ba24fac570c3852d7678a5cf8a7889eaa Mon Sep 17 00:00:00 2001 From: ralpha Date: Wed, 9 Nov 2022 15:31:11 +0100 Subject: [PATCH 1/3] Implement JsonSchema for Rocket types Implement JsonSchema for: - TempFile - NamedFile - RawStr - RawStrBuf Closes: #103 --- schemars/Cargo.toml | 1 + schemars/src/json_schema_impls/mod.rs | 2 ++ schemars/src/json_schema_impls/rocket.rs | 9 +++++++++ 3 files changed, 12 insertions(+) create mode 100644 schemars/src/json_schema_impls/rocket.rs diff --git a/schemars/Cargo.toml b/schemars/Cargo.toml index 51fd64ce..ee8dbce6 100644 --- a/schemars/Cargo.toml +++ b/schemars/Cargo.toml @@ -31,6 +31,7 @@ bytes = { version = "1.0", optional = true } rust_decimal = { version = "1", default-features = false, optional = true } bigdecimal = { version = "0.3", default-features = false, optional = true } enumset = { version = "1.0", optional = true } +rocket = { version = "0.5.0-rc.2", optional = true } [dev-dependencies] pretty_assertions = "1.2.1" diff --git a/schemars/src/json_schema_impls/mod.rs b/schemars/src/json_schema_impls/mod.rs index 99254423..9540cae6 100644 --- a/schemars/src/json_schema_impls/mod.rs +++ b/schemars/src/json_schema_impls/mod.rs @@ -60,6 +60,8 @@ mod maps; mod nonzero_signed; mod nonzero_unsigned; mod primitives; +#[cfg(feature = "rocket")] +mod rocket; mod sequences; mod serdejson; #[cfg(feature = "smallvec")] diff --git a/schemars/src/json_schema_impls/rocket.rs b/schemars/src/json_schema_impls/rocket.rs new file mode 100644 index 00000000..a6e8c0d7 --- /dev/null +++ b/schemars/src/json_schema_impls/rocket.rs @@ -0,0 +1,9 @@ +use crate::gen::SchemaGenerator; +use crate::schema::*; +use crate::JsonSchema; + +forward_impl!(rocket::fs::TempFile<'_> => Vec); +forward_impl!(rocket::fs::NamedFile => Vec); + +forward_impl!(rocket::http::RawStr => String); +forward_impl!(rocket::http::RawStrBuf => String); From 18f9e93aabb069842c1d7ae174dacb4272ae8d17 Mon Sep 17 00:00:00 2001 From: ralpha Date: Wed, 9 Nov 2022 15:45:15 +0100 Subject: [PATCH 2/3] Fixing CI --- .github/workflows/ci.yml | 5 +---- schemars/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 382c9226..d3fe33cf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,10 +35,7 @@ jobs: with: profile: minimal toolchain: ${{ matrix.rust }} - override: true - - if: matrix.rust == '1.45.0' - # work-around https://github.com/serde-rs/serde/issues/2255 and similar crate/rustc compatibility issues - run: cargo update -p serde --precise 1.0.142 && cargo update -p once_cell --precise 1.10.0 && cargo update -p pretty_assertions --precise 1.2.1 + override: true - name: Check with no feature flags run: cargo check --verbose --no-default-features continue-on-error: ${{ matrix.allow_failure }} diff --git a/schemars/Cargo.toml b/schemars/Cargo.toml index ee8dbce6..78aa21ca 100644 --- a/schemars/Cargo.toml +++ b/schemars/Cargo.toml @@ -31,7 +31,7 @@ bytes = { version = "1.0", optional = true } rust_decimal = { version = "1", default-features = false, optional = true } bigdecimal = { version = "0.3", default-features = false, optional = true } enumset = { version = "1.0", optional = true } -rocket = { version = "0.5.0-rc.2", optional = true } +rocket = { version = "0.5.0-rc.2", default-features = false, optional = true } [dev-dependencies] pretty_assertions = "1.2.1" From 07e87db932bc94159acc73e43450fd983d06993a Mon Sep 17 00:00:00 2001 From: ralpha Date: Wed, 9 Nov 2022 16:01:05 +0100 Subject: [PATCH 3/3] Fixing CI minimum Rust version support --- .github/workflows/ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d3fe33cf..eb44d26b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,6 +36,12 @@ jobs: profile: minimal toolchain: ${{ matrix.rust }} override: true + - if: matrix.rust == '1.45.0' + # Minimum Supported Rust Version + # Use fixed version for creates to support MSRV. + # Once_cell switched to MSRV 1.56.0 in 1.15.0 + # pretty_assertions switched to MSRV 1.54.0 in 1.3.0 + run: cargo update -p once_cell --precise 1.14.0 && cargo update -p pretty_assertions --precise 1.2.1 - name: Check with no feature flags run: cargo check --verbose --no-default-features continue-on-error: ${{ matrix.allow_failure }}