diff --git a/.vscode/settings.json b/.vscode/settings.json index f431dbb3..1057840c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,5 @@ { "rust-analyzer.cargo.features": "all", - "rust-analyzer.checkOnSave.command": "clippy" -} + "rust-analyzer.checkOnSave": true, + "rust-analyzer.check.command": "clippy", +} \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index db29729d..1330b138 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,12 +1,7 @@ [workspace] resolver = "2" -members = [ - "axum_serde_valid", - "serde_valid", - "serde_valid_derive", - "serde_valid_literal", -] +members = ["serde_valid", "serde_valid_derive", "serde_valid_literal"] [workspace.package] edition = "2021" diff --git a/axum_serde_valid/Cargo.toml b/axum_serde_valid/Cargo.toml deleted file mode 100644 index ca7d56a1..00000000 --- a/axum_serde_valid/Cargo.toml +++ /dev/null @@ -1,39 +0,0 @@ -[package] -name = "axum_serde_valid" -description = "Axum extractor sets of JSON validation." -authors.workspace = true -repository.workspace = true -license.workspace = true -edition.workspace = true -keywords.workspace = true -version.workspace = true - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -aide = { version = "^0.13", optional = true, features = ["axum"] } -async-trait = "^0.1" -axum = "^0.7" -http-body = "^1.0" -jsonschema = { version = "^0.17", optional = true } -schemars = { version = "^0.8", optional = true } -serde = { workspace = true } -serde_json = { workspace = true } -serde_valid = { version = "0.20.0", path = "../serde_valid", features = [ - "flatten", -] } -tracing = "^0.1" -serde_urlencoded = "0.7.1" -unic-langid-impl = { version = "0.9", optional = true } - -[dev-dependencies] -hyper = "^1.0" -mime = "0.3" -tokio = { version = "1.24", features = ["full"] } -tower = { version = "0.4", features = ["util"] } - -[features] -default = [] -jsonschema = ["dep:jsonschema", "dep:schemars"] -aide = ["dep:aide", "dep:jsonschema", "dep:schemars"] -fluent = ["serde_valid/fluent", "unic-langid-impl"] diff --git a/axum_serde_valid/README.md b/axum_serde_valid/README.md deleted file mode 100644 index 0c6783b5..00000000 --- a/axum_serde_valid/README.md +++ /dev/null @@ -1,45 +0,0 @@ -# axum_serde_valid - -[![Latest Version](https://img.shields.io/crates/v/axum_serde_valid.svg?color=green&style=flat-square)](https://crates.io/crates/axum_serde_valid) -[![Documentation](https://docs.rs/axum_serde_valid/badge.svg)](https://docs.rs/axum_serde_valid) -[![GitHub license](https://badgen.net/github/license/Naereen/Strapdown.js?style=flat-square)](https://github.com/Naereen/StrapDown.js/blob/master/LICENSE) - -This crate is a Rust library for providing validation mechanism -to [axum](https://github.com/tokio-rs/axum) with [serde_valid](https://github.com/yassun7010/serde_valid) crate. - -More information about this crate can be found in the [crate documentation](https://docs.rs/axum_serde_valid). - -### Installation - -This crate works with Cargo and can be found on [crates.io](https://crates.io/crates/axum_serde_valid) with a Cargo.toml like: - -```toml -[dependencies] -axum = "0.6" -axum_serde_valid = { version = "13", features = ["jsonschema"] } -jsonschema = "^0.16" -schemars = "0.8" -``` - -### Feature Flags - -- `jsonschema` - provide [jsonschema](https://github.com/Stranger6667/jsonschema-rs) validation. -- `aide` - support [aide](https://github.com/tamasfe/aide). - -### Example - -```rust -use axum::{routing::post, Router}; -use axum_serde_valid::Json; -use serde::Deserialize; - -#[derive(Deserialize, Validate)] -struct User { - #[validate(max_length = 3)] - name: String, -} - -let app = Router::new().route("/json", post(|user: Json| async move { "hello" })); -``` - -License: MIT diff --git a/axum_serde_valid/src/features.rs b/axum_serde_valid/src/features.rs deleted file mode 100644 index 7b52432a..00000000 --- a/axum_serde_valid/src/features.rs +++ /dev/null @@ -1,5 +0,0 @@ -#[cfg(feature = "jsonschema")] -pub mod jsonschema; - -#[cfg(feature = "fluent")] -pub mod fluent; diff --git a/axum_serde_valid/src/features/fluent.rs b/axum_serde_valid/src/features/fluent.rs deleted file mode 100644 index 6be0bec9..00000000 --- a/axum_serde_valid/src/features/fluent.rs +++ /dev/null @@ -1,20 +0,0 @@ -use unic_langid_impl::LanguageIdentifier; - -type FluentBundle = - serde_valid::export::fluent::FluentBundle; - -pub trait FluentState { - fn get_fluent_bundle(&self) -> Option<&FluentBundle>; - - fn get_fluent_bundle_on_lang(&self, lang: LanguageIdentifier) -> Option<&FluentBundle>; -} - -impl FluentState for T { - fn get_fluent_bundle(&self) -> Option<&FluentBundle> { - None - } - - fn get_fluent_bundle_on_lang(&self, _lang: LanguageIdentifier) -> Option<&FluentBundle> { - None - } -} diff --git a/axum_serde_valid/src/features/jsonschema.rs b/axum_serde_valid/src/features/jsonschema.rs deleted file mode 100644 index 4f61f600..00000000 --- a/axum_serde_valid/src/features/jsonschema.rs +++ /dev/null @@ -1,3 +0,0 @@ -mod context; - -pub(crate) use context::SchemaContext; diff --git a/axum_serde_valid/src/features/jsonschema/context.rs b/axum_serde_valid/src/features/jsonschema/context.rs deleted file mode 100644 index 24b47d39..00000000 --- a/axum_serde_valid/src/features/jsonschema/context.rs +++ /dev/null @@ -1,61 +0,0 @@ -use std::{ - any::{type_name, TypeId}, - cell::RefCell, - collections::{HashMap, VecDeque}, -}; - -use jsonschema::{ - output::{BasicOutput, ErrorDescription, OutputUnit}, - JSONSchema, -}; -use schemars::gen::{SchemaGenerator, SchemaSettings}; -use serde_json::{Map, Value}; - -thread_local! { - static CONTEXT: RefCell = RefCell::new(SchemaContext::new()); -} - -pub(crate) struct SchemaContext { - pub generator: SchemaGenerator, - pub schemas: HashMap, -} - -impl SchemaContext { - pub fn new() -> Self { - Self { - generator: SchemaSettings::draft07() - .with(|settings| settings.inline_subschemas = true) - .into_generator(), - schemas: HashMap::default(), - } - } - - pub fn validate(value: &Value) -> Result<(), VecDeque>> - where - T: crate::traits::validated::Deserialize + schemars::JsonSchema + 'static, - { - CONTEXT.with(|ctx| { - let ctx = &mut *ctx.borrow_mut(); - let schema = ctx.schemas.entry(TypeId::of::()).or_insert_with(|| { - match jsonschema::JSONSchema::compile( - &serde_json::to_value(ctx.generator.root_schema_for::()).unwrap(), - ) { - Ok(s) => s, - Err(error) => { - tracing::error!( - %error, - type_name = type_name::(), - "invalid JSON schema for type" - ); - JSONSchema::compile(&Value::Object(Map::default())).unwrap() - } - } - }); - - match schema.apply(value).basic() { - BasicOutput::Valid(_) => Ok(()), - BasicOutput::Invalid(v) => Err(v), - } - }) - } -} diff --git a/axum_serde_valid/src/json.rs b/axum_serde_valid/src/json.rs deleted file mode 100644 index 3b31b6db..00000000 --- a/axum_serde_valid/src/json.rs +++ /dev/null @@ -1,237 +0,0 @@ -#![cfg_attr(docsrs, feature(doc_auto_cfg))] -//! A simple crate provides a drop-in replacement for [`axum::Json`] -//! that uses [jsonschema](https://docs.rs/jsonschema/latest/jsonschema/) to validate requests schemas -//! generated via [schemars](https://docs.rs/schemars/latest/schemars/). -//! -//! You might want to do this in order to provide a better -//! experience for your clients and not leak serde's error messages. -//! -//! All schemas are cached in a thread-local storage for -//! the life of the application (or thread). -//! -//! # Features -//! -//! - aide: support for [aide](https://docs.rs/aide/latest/aide/) - -use async_trait::async_trait; -use axum::extract::Request; -use axum::{extract::FromRequest, response::IntoResponse}; -use serde::Serialize; -use std::ops::Deref; - -/// Wrapper type over [`axum::Json`] that validates -/// requests and responds with a more helpful validation -/// message. -pub struct Json(pub T); - -impl Deref for Json { - type Target = T; - - fn deref(&self) -> &Self::Target { - &self.0 - } -} - -impl From for Json { - fn from(data: T) -> Self { - Json(data) - } -} - -#[async_trait] -impl FromRequest for Json -where - T: crate::traits::validated::Deserialize + 'static, - S: crate::traits::state::State, -{ - type Rejection = crate::rejection::Rejection; - - async fn from_request(req: Request, state: &S) -> Result { - crate::request::from_request::<_, T>(req, state) - .await - .map(Json) - } -} - -impl IntoResponse for Json -where - T: Serialize, -{ - fn into_response(self) -> axum::response::Response { - axum::Json(self.0).into_response() - } -} - -#[cfg(feature = "aide")] -mod impl_aide { - use super::*; - - impl aide::OperationInput for Json - where - T: schemars::JsonSchema, - { - fn operation_input( - ctx: &mut aide::gen::GenContext, - operation: &mut aide::openapi::Operation, - ) { - axum::Json::::operation_input(ctx, operation); - } - } - - impl aide::OperationOutput for Json - where - T: schemars::JsonSchema, - { - type Inner = as aide::OperationOutput>::Inner; - - fn operation_response( - ctx: &mut aide::gen::GenContext, - op: &mut aide::openapi::Operation, - ) -> Option { - axum::Json::::operation_response(ctx, op) - } - - fn inferred_responses( - ctx: &mut aide::gen::GenContext, - operation: &mut aide::openapi::Operation, - ) -> Vec<(Option, aide::openapi::Response)> { - axum::Json::::inferred_responses(ctx, operation) - } - } -} - -#[cfg(test)] -mod test { - use crate::Json; - use axum::http::StatusCode; - use axum::{ - body::Body, - http::{self, Request}, - }; - use serde::Deserialize; - use serde_json::json; - use serde_valid::Validate; - use tower::ServiceExt; - - type TestResult = Result<(), Box>; - - #[cfg(all(not(feature = "jsonschema"), not(feature = "aide")))] - #[tokio::test] - async fn test_json() -> TestResult { - use axum::{routing::post, Router}; - - #[derive(Deserialize, Validate)] - struct User { - #[validate(max_length = 3)] - name: String, - } - - let app = Router::new().route("/json", post(|_user: Json| async move { "hello" })); - - let response = app - .oneshot( - Request::builder() - .method(http::Method::POST) - .uri("/json") - .header(http::header::CONTENT_TYPE, mime::APPLICATION_JSON.as_ref()) - .body(Body::from(serde_json::to_vec(&json!({"name": "taro"}))?))?, - ) - .await?; - - assert_eq!(response.status(), StatusCode::UNPROCESSABLE_ENTITY); - assert_eq!( - serde_json::from_slice::( - &axum::body::to_bytes(response.into_body(), 1_000_000).await?, - )?, - json!({"errors": [ - { - "error": "The length of the value must be `<= 3`.", - "instance_location": "/name", - "keyword_location": null - } - ]}) - ); - - Ok(()) - } - - #[cfg(feature = "jsonschema")] - #[tokio::test] - async fn test_json_with_jsonschema() -> TestResult { - use axum::{routing::post, Router}; - - #[derive(Deserialize, Validate, schemars::JsonSchema)] - struct User { - #[validate(max_length = 3)] - name: String, - } - - let app = Router::new().route("/json", post(|_user: Json| async move { "hello" })); - - let response = app - .oneshot( - Request::builder() - .method(http::Method::POST) - .uri("/json") - .header(http::header::CONTENT_TYPE, mime::APPLICATION_JSON.as_ref()) - .body(Body::from(serde_json::to_vec(&json!({"name": "taro"}))?))?, - ) - .await?; - - assert_eq!(response.status(), StatusCode::UNPROCESSABLE_ENTITY); - assert_eq!( - serde_json::from_slice::( - &axum::body::to_bytes(response.into_body(), 1_000_000).await? - )?, - json!({"errors": [ - { - "error": "The length of the value must be `<= 3`.", - "instance_location": "/name", - "keyword_location": null - } - ]}) - ); - - Ok(()) - } - - #[cfg(feature = "aide")] - #[tokio::test] - async fn test_json_with_aide() -> TestResult { - use aide::axum::{routing::post, ApiRouter}; - - #[derive(Deserialize, Validate, schemars::JsonSchema)] - struct User { - #[validate(max_length = 3)] - name: String, - } - - let app = ApiRouter::new().route("/json", post(|_user: Json| async move { "hello" })); - - let response = app - .oneshot( - Request::builder() - .method(http::Method::POST) - .uri("/json") - .header(http::header::CONTENT_TYPE, mime::APPLICATION_JSON.as_ref()) - .body(Body::from(serde_json::to_vec(&json!({"name": "taro"}))?))?, - ) - .await?; - - assert_eq!(response.status(), StatusCode::UNPROCESSABLE_ENTITY); - assert_eq!( - serde_json::from_slice::( - &axum::body::to_bytes(response.into_body(), 1_000_000).await?, - )?, - json!({"errors": [ - { - "error": "The length of the value must be `<= 3`.", - "instance_location": "/name", - "keyword_location": null - } - ]}) - ); - - Ok(()) - } -} diff --git a/axum_serde_valid/src/json_pointer.rs b/axum_serde_valid/src/json_pointer.rs deleted file mode 100644 index bc6cd6d3..00000000 --- a/axum_serde_valid/src/json_pointer.rs +++ /dev/null @@ -1,40 +0,0 @@ -use std::ops::Deref; - -use serde::Serialize; - -#[derive(Debug, Default, Serialize)] -pub struct JsonPointer(pub String); - -impl Deref for JsonPointer { - type Target = String; - - fn deref(&self) -> &Self::Target { - &self.0 - } -} - -#[cfg(feature = "aide")] -mod jsonschema { - use schemars::{ - gen::SchemaGenerator, - schema::{InstanceType, Schema, SchemaObject}, - JsonSchema, - }; - - use super::JsonPointer; - - impl JsonSchema for JsonPointer { - fn schema_name() -> String { - "JsonPointer".to_owned() - } - - fn json_schema(_: &mut SchemaGenerator) -> Schema { - SchemaObject { - instance_type: Some(InstanceType::String.into()), - format: None, - ..Default::default() - } - .into() - } - } -} diff --git a/axum_serde_valid/src/lib.rs b/axum_serde_valid/src/lib.rs deleted file mode 100644 index 32908c31..00000000 --- a/axum_serde_valid/src/lib.rs +++ /dev/null @@ -1,12 +0,0 @@ -mod features; -mod json; -pub mod json_pointer; -mod query; -pub mod rejection; -mod request; -pub mod traits; - -#[allow(unused_imports)] -pub use features::*; -pub use json::Json; -pub use query::Query; diff --git a/axum_serde_valid/src/query.rs b/axum_serde_valid/src/query.rs deleted file mode 100644 index 66ba2338..00000000 --- a/axum_serde_valid/src/query.rs +++ /dev/null @@ -1,79 +0,0 @@ -#![cfg_attr(docsrs, feature(doc_auto_cfg))] -//! A simple crate provides a drop-in replacement for [`axum::extract::Query`] -//! that uses [jsonschema](https://docs.rs/jsonschema/latest/jsonschema/) to validate requests schemas -//! generated via [schemars](https://docs.rs/schemars/latest/schemars/). -//! -//! You might want to do this in order to provide a better -//! experience for your clients and not leak serde's error messages. -//! -//! All schemas are cached in a thread-local storage for -//! the life of the application (or thread). -//! -//! # Features -//! -//! - aide: support for [aide](https://docs.rs/aide/latest/aide/) - -use std::ops::Deref; - -use async_trait::async_trait; -use axum::extract::FromRequestParts; -use axum::http::request::Parts; -use serde::de::DeserializeOwned; - -/// Wrapper type over [`axum::extract::Query`] that validates -/// requests with a more helpful validation -/// message. -pub struct Query(pub T); - -#[async_trait] -impl FromRequestParts for Query -where - T: DeserializeOwned + serde_valid::Validate, - S: Send + Sync, -{ - type Rejection = crate::rejection::Rejection; - - async fn from_request_parts(parts: &mut Parts, _state: &S) -> Result { - let query = parts.uri.query().unwrap_or_default(); - match serde_urlencoded::from_str::(query) { - Ok(v) => { - v.validate() - .map_err(crate::rejection::Rejection::SerdeValid)?; - - Ok(Query(v)) - } - Err(error) => Err(crate::rejection::Rejection::SerdeUrlEncoded(error)), - } - } -} - -impl Deref for Query { - type Target = T; - - fn deref(&self) -> &Self::Target { - &self.0 - } -} - -impl From for Query { - fn from(data: T) -> Self { - Query(data) - } -} - -#[cfg(feature = "aide")] -mod impl_aide { - use super::*; - - impl aide::OperationInput for Query - where - T: schemars::JsonSchema, - { - fn operation_input( - ctx: &mut aide::gen::GenContext, - operation: &mut aide::openapi::Operation, - ) { - axum::extract::Query::::operation_input(ctx, operation); - } - } -} diff --git a/axum_serde_valid/src/rejection.rs b/axum_serde_valid/src/rejection.rs deleted file mode 100644 index 4361c89d..00000000 --- a/axum_serde_valid/src/rejection.rs +++ /dev/null @@ -1,150 +0,0 @@ -use axum::{extract::rejection::JsonRejection, http::StatusCode, response::IntoResponse}; -use serde::Serialize; -use serde_valid::flatten::IntoFlat; - -use crate::json_pointer::JsonPointer; - -/// Rejection for [`axum::Json`]. -#[derive(Debug)] -pub enum Rejection { - /// A rejection returned by [`axum::Json`]. - Json(JsonRejection), - /// A serde json error. - SerdeJson(serde_json::Error), - /// A serde url encoded error. - SerdeUrlEncoded(serde_urlencoded::de::Error), - /// A serde_valid validation error. - SerdeValid(serde_valid::validation::Errors), - #[cfg(feature = "jsonschema")] - /// A schema validation error. - Jsonschema( - std::collections::VecDeque< - jsonschema::output::OutputUnit, - >, - ), -} - -#[cfg(not(feature = "aide"))] -#[derive(Debug, Serialize)] -pub enum JsonErrorResponse { - FormatError(String), - ValidationError(JsonSchemaErrorResponse), -} - -#[cfg(feature = "aide")] -#[derive(Debug, Serialize, schemars::JsonSchema)] -pub enum JsonErrorResponse { - FormatError(String), - ValidationError(JsonSchemaErrorResponse), -} - -#[cfg(not(feature = "aide"))] -#[derive(Debug, Serialize)] -pub struct JsonSchemaErrorResponse { - errors: Vec, -} - -#[cfg(feature = "aide")] -#[derive(Debug, Serialize, schemars::JsonSchema)] -pub struct JsonSchemaErrorResponse { - errors: Vec, -} - -#[cfg(not(feature = "aide"))] -#[derive(Debug, Serialize)] -pub struct Error { - pub error: String, - pub instance_location: JsonPointer, - pub keyword_location: Option, -} - -#[cfg(feature = "aide")] -#[derive(Debug, Serialize, schemars::JsonSchema)] -pub struct Error { - pub error: String, - pub instance_location: JsonPointer, - pub keyword_location: Option, -} - -impl From for JsonErrorResponse { - fn from(rejection: Rejection) -> Self { - match rejection { - Rejection::Json(error) => Self::FormatError(error.to_string()), - Rejection::SerdeJson(error) => Self::FormatError(error.to_string()), - Rejection::SerdeUrlEncoded(error) => Self::FormatError(error.to_string()), - Rejection::SerdeValid(errors) => { - let iter = errors.into_flat().into_iter().map(|err| Error { - error: err.error, - instance_location: JsonPointer(err.instance_location.to_string()), - keyword_location: None, - }); - - Self::ValidationError(JsonSchemaErrorResponse { - errors: iter.collect::>(), - }) - } - #[cfg(feature = "jsonschema")] - Rejection::Jsonschema(errors) => Self::ValidationError(JsonSchemaErrorResponse { - errors: errors - .into_iter() - .map(|err| Error { - error: err.error_description().to_string(), - instance_location: JsonPointer(err.instance_location().to_string()), - keyword_location: Some(JsonPointer(err.keyword_location().to_string())), - }) - .collect::>(), - }), - } - } -} - -impl IntoResponse for Rejection { - fn into_response(self) -> axum::response::Response { - match JsonErrorResponse::from(self) { - JsonErrorResponse::FormatError(error) => { - let mut response = axum::Json(error).into_response(); - *response.status_mut() = StatusCode::BAD_REQUEST; - response - } - JsonErrorResponse::ValidationError(error) => { - let mut response = axum::Json(error).into_response(); - *response.status_mut() = StatusCode::UNPROCESSABLE_ENTITY; - response - } - } - } -} - -#[cfg(feature = "aide")] -mod impl_aide { - use super::*; - - impl aide::OperationOutput for Rejection { - type Inner = Self; - - fn operation_response( - ctx: &mut aide::gen::GenContext, - operation: &mut aide::openapi::Operation, - ) -> Option { - axum::Json::::operation_response(ctx, operation) - } - - fn inferred_responses( - ctx: &mut aide::gen::GenContext, - operation: &mut aide::openapi::Operation, - ) -> Vec<(Option, aide::openapi::Response)> { - let mut responses = vec![]; - - if let Some(response) = String::operation_response(ctx, operation) { - responses.push((Some(StatusCode::BAD_REQUEST.into()), response)); - } - if let Some(response) = - axum::Json::::operation_response(ctx, operation) - { - responses.push((Some(StatusCode::UNPROCESSABLE_ENTITY.into()), response)); - } - - responses - } - } -} diff --git a/axum_serde_valid/src/request.rs b/axum_serde_valid/src/request.rs deleted file mode 100644 index 5b886f1f..00000000 --- a/axum_serde_valid/src/request.rs +++ /dev/null @@ -1,41 +0,0 @@ -use std::any::type_name; - -use axum::extract::FromRequest; -use serde_json::Value; - -pub async fn from_request( - req: axum::extract::Request, - state: &S, -) -> Result -where - S: crate::traits::state::State, - T: crate::traits::validated::Deserialize + 'static, -{ - let value: Value = match axum::Json::from_request(req, state).await { - Ok(j) => j.0, - Err(error) => Err(crate::rejection::Rejection::Json(error))?, - }; - - #[cfg(feature = "jsonschema")] - { - crate::jsonschema::SchemaContext::validate::(&value) - .map_err(crate::rejection::Rejection::Jsonschema)?; - } - - match serde_json::from_value::(value) { - Ok(v) => { - v.validate() - .map_err(crate::rejection::Rejection::SerdeValid)?; - - Ok(v) - } - Err(error) => { - tracing::error!( - %error, - type_name = type_name::(), - "schema validation passed but serde failed" - ); - Err(crate::rejection::Rejection::SerdeJson(error)) - } - } -} diff --git a/axum_serde_valid/src/traits.rs b/axum_serde_valid/src/traits.rs deleted file mode 100644 index 937fb20d..00000000 --- a/axum_serde_valid/src/traits.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod state; -pub mod validated; diff --git a/axum_serde_valid/src/traits/state.rs b/axum_serde_valid/src/traits/state.rs deleted file mode 100644 index b4bfe22b..00000000 --- a/axum_serde_valid/src/traits/state.rs +++ /dev/null @@ -1,17 +0,0 @@ -#[cfg(feature = "fluent")] -mod inner { - use crate::fluent::FluentState; - - pub trait State: Send + Sync + FluentState {} - - impl State for T where T: Send + Sync + FluentState {} -} - -#[cfg(not(feature = "fluent"))] -mod inner { - pub trait State: Send + Sync {} - - impl State for T where T: Send + Sync {} -} - -pub use inner::State; diff --git a/axum_serde_valid/src/traits/validated.rs b/axum_serde_valid/src/traits/validated.rs deleted file mode 100644 index a81519a5..00000000 --- a/axum_serde_valid/src/traits/validated.rs +++ /dev/null @@ -1,21 +0,0 @@ -#[cfg(not(any(feature = "jsonschema", feature = "aide")))] -mod deserialize { - pub trait Deserialize: serde::de::DeserializeOwned + serde_valid::Validate {} - - impl Deserialize for T where T: serde::de::DeserializeOwned + serde_valid::Validate {} -} - -#[cfg(any(feature = "jsonschema", feature = "aide"))] -mod deserialize { - pub trait Deserialize: - serde::de::DeserializeOwned + serde_valid::Validate + schemars::JsonSchema - { - } - - impl Deserialize for T where - T: serde::de::DeserializeOwned + serde_valid::Validate + schemars::JsonSchema - { - } -} - -pub use deserialize::Deserialize; diff --git a/scripts/publish.sh b/scripts/publish.sh index 2550d023..b9a3d8a3 100755 --- a/scripts/publish.sh +++ b/scripts/publish.sh @@ -15,9 +15,3 @@ sleep 20 cd ../serde_valid cargo publish - -# wait tarball package publishment -sleep 20 - -cd ../axum_serde_valid -cargo publish diff --git a/serde_valid.code-workspace b/serde_valid.code-workspace index 6057dfb2..b3ddab35 100644 --- a/serde_valid.code-workspace +++ b/serde_valid.code-workspace @@ -8,10 +8,6 @@ "name": "docs", "path": "docs", }, - { - "name": "axum_serde_valid", - "path": "axum_serde_valid" - }, { "name": "serde_valid_derive", "path": "serde_valid_derive" @@ -27,7 +23,8 @@ ], "settings": { "rust-analyzer.cargo.features": "all", - "rust-analyzer.checkOnSave.command": "clippy", + "rust-analyzer.checkOnSave": true, + "rust-analyzer.check.command": "clippy", }, "extensions": { "recommendations": [ diff --git a/serde_valid_literal/Cargo.toml b/serde_valid_literal/Cargo.toml index 4e36d881..91575947 100644 --- a/serde_valid_literal/Cargo.toml +++ b/serde_valid_literal/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "serde_valid_literal" description = "Literal Value type based JSON." -categories = ["axum", "json", "jsonschema", "validation", "serde"] +categories = [] authors.workspace = true repository.workspace = true license.workspace = true