Skip to content

Commit

Permalink
Add ToSchema implementation for serde_json::Value (#1132)
Browse files Browse the repository at this point in the history
This commit adds direct `ToSchema` implementation for `serde_json::Value`.

Fixes #1128
  • Loading branch information
juhaku authored Oct 15, 2024
1 parent 5c1ed4c commit 8901107
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions utoipa/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ to look into changes introduced to **`utoipa-gen`**.
### Added

* Implement schema traits for indexset (https://github.com/juhaku/utoipa/pull/1129)
* Add `ToSchema` implementation for serde_json::Value (https://github.com/juhaku/utoipa/pull/1132)

## 5.0.0 - Oct 14 2024

Expand Down
10 changes: 10 additions & 0 deletions utoipa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,16 @@ where
}
}

impl PartialSchema for serde_json::Value {
fn schema() -> openapi::RefOr<openapi::schema::Schema> {
utoipa::openapi::schema::Object::builder()
.schema_type(utoipa::openapi::schema::SchemaType::AnyValue)
.into()
}
}

impl ToSchema for serde_json::Value {}

// Create `utoipa` module so we can use `utoipa-gen` directly from `utoipa` crate.
// ONLY for internal use!
#[doc(hidden)]
Expand Down

0 comments on commit 8901107

Please sign in to comment.