File tree Expand file tree Collapse file tree 3 files changed +30
-1
lines changed Expand file tree Collapse file tree 3 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,8 @@ and this project adheres to
23
23
` -Zminimal-versions ` ([ #1465 ] ).
24
24
- cosmwasm-profiler: Package was removed 🪦. It served its job showing us that we
25
25
cannot properly measure different runtimes for differet Wasm opcodes.
26
+ - cosmwasm-schema: schema generation is now locked to produce strictly
27
+ ` draft-07 ` schemas
26
28
27
29
[ #1465 ] : https://github.com/CosmWasm/cosmwasm/pull/1465
28
30
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ mod export;
3
3
mod idl;
4
4
mod query_response;
5
5
mod remove;
6
+ mod schema_for;
6
7
7
8
pub use export:: { export_schema, export_schema_with_title} ;
8
9
pub use idl:: { Api , IDL_VERSION } ;
@@ -91,7 +92,6 @@ pub use cosmwasm_schema_derive::generate_api;
91
92
/// };
92
93
/// ```
93
94
pub use cosmwasm_schema_derive:: write_api;
94
- pub use schemars:: schema_for;
95
95
96
96
// For use in macro expansions
97
97
pub use schemars;
Original file line number Diff line number Diff line change
1
+ /// Generates a [`RootSchema`](crate::schemars::schema::RootSchema) for the given type using default settings.
2
+ ///
3
+ /// The type must implement [`JsonSchema`](crate::schemars::JsonSchema).
4
+ ///
5
+ /// The schema version is strictly `draft-07`.
6
+ ///
7
+ /// # Example
8
+ /// ```
9
+ /// use cosmwasm_schema::schema_for;
10
+ /// use schemars::JsonSchema;
11
+ ///
12
+ /// #[derive(JsonSchema)]
13
+ /// struct MyStruct {
14
+ /// foo: i32,
15
+ /// }
16
+ ///
17
+ /// let my_schema = schema_for!(MyStruct);
18
+ /// ```
19
+ #[ macro_export]
20
+ macro_rules! schema_for {
21
+ ( $type: ty) => {
22
+ $crate:: schemars:: gen :: SchemaGenerator :: new( $crate:: schemars:: gen :: SchemaSettings :: draft07( ) ) . into_root_schema_for:: <$type>( )
23
+ } ;
24
+ ( $_: expr) => {
25
+ compile_error!( "The argument to `schema_for!` is not a type." )
26
+ } ;
27
+ }
You can’t perform that action at this time.
0 commit comments