Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a re-exported serde_json dependency in macros #1243

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ authors = [
[dependencies]
actix-web = "4"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
env_logger = "0.11.0"
log = "0.4"
futures = "0.3"
Expand Down
1 change: 0 additions & 1 deletion examples/actix-web-scopes-binding/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ edition = "2021"
[dependencies]
actix-web = "4"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
env_logger = "0.11.0"
log = "0.4"
futures = "0.3"
Expand Down
1 change: 0 additions & 1 deletion examples/axum-multipart/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@ utoipa = { version = "5", features = ["axum_extras"] }
utoipa-swagger-ui = { version = "8", features = ["axum"] }
utoipa-axum = "0.1"
serde = { features = ["derive"], version = "1" }
serde_json = "1"

[workspace]
1 change: 0 additions & 1 deletion examples/axum-utoipa-bindings/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@ utoipa = { path = "../../utoipa", features = ["axum_extras", "debug"] }
utoipa-swagger-ui = { path = "../../utoipa-swagger-ui", features = ["axum"] }
utoipa-axum = { path = "../../utoipa-axum" ,features = ["debug"] }
serde = "1"
serde_json = "1"

[workspace]
1 change: 0 additions & 1 deletion examples/axum-utoipa-nesting-vendored/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ tower = "0.5"
utoipa = { path = "../../utoipa", features = ["axum_extras"] }
utoipa-swagger-ui = { path = "../../utoipa-swagger-ui", features = ["axum", "vendored"], default-features = false }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
env_logger = "0.11"
log = "0.4"

Expand Down
1 change: 0 additions & 1 deletion examples/generics-actix/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ actix-web = "4"
env_logger = "0.10.0"
geo-types = { version = "0.7", features = ["serde"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
utoipa = { path = "../../utoipa", features = ["actix_extras", "non_strict_integers"] }
utoipa-swagger-ui = { path = "../../utoipa-swagger-ui", features = ["actix-web"] }

Expand Down
1 change: 0 additions & 1 deletion examples/todo-actix/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ authors = ["Example <[email protected]>"]
[dependencies]
actix-web = "4"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
env_logger = "0.11"
log = "0.4"
futures = "0.3"
Expand Down
1 change: 0 additions & 1 deletion examples/todo-axum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,5 @@ utoipa-redoc = { path = "../../utoipa-redoc", features = ["axum"] }
utoipa-rapidoc = { path = "../../utoipa-rapidoc", features = ["axum"] }
utoipa-scalar = { path = "../../utoipa-scalar", features = ["axum"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"

[workspace]
1 change: 0 additions & 1 deletion examples/todo-warp-rapidoc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ authors = [
tokio = { version = "1", features = ["full"] }
warp = "0.3"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
env_logger = "0.11.0"
log = "0.4"
futures = "0.3"
Expand Down
1 change: 0 additions & 1 deletion examples/todo-warp-redoc-with-file-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ authors = ["Elli Example <[email protected]>"]
tokio = { version = "1", features = ["full"] }
warp = "0.3"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
env_logger = "0.11.0"
log = "0.4"
futures = "0.3"
Expand Down
1 change: 0 additions & 1 deletion examples/todo-warp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ authors = [
tokio = { version = "1", features = ["full"] }
warp = "0.3"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
env_logger = "0.11.0"
log = "0.4"
futures = "0.3"
Expand Down
1 change: 0 additions & 1 deletion examples/warp-multiple-api-docs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ authors = [
tokio = { version = "1", features = ["full"] }
warp = "0.3"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
env_logger = "0.10.0"
log = "0.4"
futures = "0.3"
Expand Down
6 changes: 2 additions & 4 deletions utoipa-gen/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@

## Unreleased

### Changed

* Simplified `ToTokensDiagnostics` for `request_body` (https://github.com/juhaku/utoipa/pull/1235)

### Fixed

* Fix tagged enum with flatten fields (https://github.com/juhaku/utoipa/pull/1208)

### Changed

* Use a re-exported `serde_json` dependency in macros instead of implicitly requiring it as dependency in end projects (https://github.com/juhaku/utoipa/pull/1243)
* Simplified `ToTokensDiagnostics` for `request_body` (https://github.com/juhaku/utoipa/pull/1235)
* `Info::from_env()` sets `License::identifier` (https://github.com/juhaku/utoipa/pull/1233)

### Added
Expand Down
2 changes: 1 addition & 1 deletion utoipa-gen/src/component/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ impl UnitStructVariant {
let mut tokens = quote! {
utoipa::openapi::Object::builder()
.schema_type(utoipa::openapi::schema::SchemaType::AnyValue)
.default(Some(serde_json::Value::Null))
.default(Some(utoipa::gen::serde_json::Value::Null))
};

let mut features = features::parse_schema_features_with(root.attributes, |input| {
Expand Down
2 changes: 1 addition & 1 deletion utoipa-gen/src/component/schema/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ where
tokens.extend(quote! {
utoipa::openapi::schema::Object::builder()
.schema_type(utoipa::openapi::schema::Type::Null)
.default(Some(serde_json::Value::Null))
.default(Some(utoipa::gen::serde_json::Value::Null))
})
}

Expand Down
4 changes: 2 additions & 2 deletions utoipa-gen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3341,14 +3341,14 @@ impl ToTokens for AnyValue {
fn to_tokens(&self, tokens: &mut TokenStream2) {
match self {
Self::Json(json) => tokens.extend(quote! {
serde_json::json!(#json)
utoipa::gen::serde_json::json!(#json)
}),
Self::String(string) => string.to_tokens(tokens),
Self::DefaultTrait {
struct_ident,
field_ident,
} => tokens.extend(quote! {
serde_json::to_value(#struct_ident::default().#field_ident).unwrap()
utoipa::gen::serde_json::to_value(#struct_ident::default().#field_ident).unwrap()
}),
}
}
Expand Down
4 changes: 4 additions & 0 deletions utoipa/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ to look into changes introduced to **`utoipa-gen`**.

* Fix diverging axum route and openapi spec (https://github.com/juhaku/utoipa/pull/1199)

### Changed

* Use a re-exported `serde_json` dependency in macros instead of implicitly requiring it as dependency in end projects (https://github.com/juhaku/utoipa/pull/1243)

## 5.2.0 - Nov 2024

### Changed
Expand Down
1 change: 1 addition & 0 deletions utoipa/src/gen.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub use serde_json;
6 changes: 6 additions & 0 deletions utoipa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,12 @@
pub mod openapi;

#[cfg(feature = "macros")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "macros")))]
#[doc(hidden)]
/// Public re-exports for utoipa-gen.
pub mod gen;

use std::borrow::Cow;
use std::collections::BTreeMap;
use std::option::Option;
Expand Down
Loading