Skip to content

Commit c4aa695

Browse files
committed
Add to cw_serde
1 parent 9e971d6 commit c4aa695

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/schema-derive/src/cw_serde.rs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ impl Parse for Options {
3939
pub fn cw_serde_impl(options: Options, input: DeriveInput) -> syn::Result<DeriveInput> {
4040
let crate_path = &options.crate_path;
4141
let crate_path_displayable = crate_path.to_token_stream();
42+
43+
let cw_schema_path = format!("{crate_path_displayable}::cw_schema");
4244
let serde_path = format!("{crate_path_displayable}::serde");
4345
let schemars_path = format!("{crate_path_displayable}::schemars");
4446

@@ -49,10 +51,12 @@ pub fn cw_serde_impl(options: Options, input: DeriveInput) -> syn::Result<Derive
4951
::std::clone::Clone,
5052
::std::fmt::Debug,
5153
::std::cmp::PartialEq,
52-
#crate_path::schemars::JsonSchema
54+
#crate_path::schemars::JsonSchema,
55+
#crate_path::cw_schema::Schemaifier,
5356
)]
5457
#[allow(clippy::derive_partial_eq_without_eq)] // Allow users of `#[cw_serde]` to not implement Eq without clippy complaining
5558
#[serde(crate = #serde_path)]
59+
#[schemaifier(crate = #cw_schema_path)]
5660
#[schemars(crate = #schemars_path)]
5761
};
5862

@@ -95,10 +99,12 @@ mod tests {
9599
::std::clone::Clone,
96100
::std::fmt::Debug,
97101
::std::cmp::PartialEq,
98-
::my_crate::cw_schema::schemars::JsonSchema
102+
::my_crate::cw_schema::schemars::JsonSchema,
103+
::my_crate::cw_schema::cw_schema::Schemaifier,
99104
)]
100105
#[allow(clippy::derive_partial_eq_without_eq)]
101106
#[serde(crate = ":: my_crate :: cw_schema::serde")]
107+
#[schemaifier(crate = ":: my_crate :: cw_schema::cw_schema")]
102108
#[schemars(crate = ":: my_crate :: cw_schema::schemars")]
103109
pub struct InstantiateMsg {
104110
pub verifier: String,
@@ -129,10 +135,12 @@ mod tests {
129135
::std::clone::Clone,
130136
::std::fmt::Debug,
131137
::std::cmp::PartialEq,
132-
::cosmwasm_schema::schemars::JsonSchema
138+
::cosmwasm_schema::schemars::JsonSchema,
139+
::cosmwasm_schema::cw_schema::Schemaifier,
133140
)]
134141
#[allow(clippy::derive_partial_eq_without_eq)]
135142
#[serde(crate = ":: cosmwasm_schema::serde")]
143+
#[schemaifier(crate = ":: cosmwasm_schema::cw_schema")]
136144
#[schemars(crate = ":: cosmwasm_schema::schemars")]
137145
pub struct InstantiateMsg {
138146
pub verifier: String,
@@ -160,10 +168,12 @@ mod tests {
160168
::std::clone::Clone,
161169
::std::fmt::Debug,
162170
::std::cmp::PartialEq,
163-
::cosmwasm_schema::schemars::JsonSchema
171+
::cosmwasm_schema::schemars::JsonSchema,
172+
::cosmwasm_schema::cw_schema::Schemaifier,
164173
)]
165174
#[allow(clippy::derive_partial_eq_without_eq)]
166175
#[serde(crate = ":: cosmwasm_schema::serde")]
176+
#[schemaifier(crate = ":: cosmwasm_schema::cw_schema")]
167177
#[schemars(crate = ":: cosmwasm_schema::schemars")]
168178
pub struct InstantiateMsg {}
169179
};
@@ -193,10 +203,12 @@ mod tests {
193203
::std::clone::Clone,
194204
::std::fmt::Debug,
195205
::std::cmp::PartialEq,
196-
::cosmwasm_schema::schemars::JsonSchema
206+
::cosmwasm_schema::schemars::JsonSchema,
207+
::cosmwasm_schema::cw_schema::Schemaifier,
197208
)]
198209
#[allow(clippy::derive_partial_eq_without_eq)]
199210
#[serde(crate = ":: cosmwasm_schema::serde")]
211+
#[schemaifier(crate = ":: cosmwasm_schema::cw_schema")]
200212
#[schemars(crate = ":: cosmwasm_schema::schemars")]
201213
#[serde(rename_all = "snake_case")]
202214
pub enum SudoMsg {

packages/schema/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ license = "Apache-2.0"
99

1010
[dependencies]
1111
cosmwasm-schema-derive = { version = "=2.1.1", path = "../schema-derive" }
12+
cw-schema = { version = "=2.1.1", path = "../cw-schema" }
1213
schemars = { workspace = true }
1314
serde = { workspace = true }
1415
serde_json = "1.0.40"

packages/schema/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,6 @@ pub use cosmwasm_schema_derive::generate_api;
9494
pub use cosmwasm_schema_derive::write_api;
9595

9696
// For use in macro expansions
97+
pub use cw_schema;
9798
pub use schemars;
9899
pub use serde;

0 commit comments

Comments
 (0)