cosmwasm_schema/lib.rs
1mod casing;
2mod export;
3mod idl;
4mod query_response;
5mod remove;
6mod schema_for;
7
8pub use export::{export_schema, export_schema_with_title};
9pub use idl::{Api, IDL_VERSION};
10pub use query_response::{combine_subqueries, IntegrityError, QueryResponses};
11pub use remove::remove_schemas;
12
13// Re-exports
14/// An attribute macro that annotates types with things they need to be properly (de)serialized
15/// for use in CosmWasm contract messages and/or responses, and also for schema generation.
16///
17/// This derives things like `serde::Serialize` or `schemars::JsonSchema`, makes sure
18/// variants are `snake_case` in the resulting JSON, and so forth.
19///
20/// # Example
21/// ```
22/// use cosmwasm_schema::{cw_serde, QueryResponses};
23///
24/// #[cw_serde]
25/// pub struct InstantiateMsg {
26/// owner: String,
27/// }
28///
29/// #[cw_serde]
30/// #[derive(QueryResponses)]
31/// pub enum QueryMsg {
32/// #[returns(Vec<String>)]
33/// Denoms {},
34/// #[returns(String)]
35/// AccountName { account: String },
36/// }
37/// ```
38pub use cosmwasm_schema_derive::cw_serde;
39/// Generates an [`Api`](crate::Api) for the contract. The body describes the message
40/// types exported in the schema and allows setting contract name and version overrides.
41///
42/// The only obligatory field is `instantiate` - to set the InstantiateMsg type.
43///
44/// # Available fields
45/// See [`write_api`](crate::write_api).
46///
47/// # Example
48/// ```
49/// use cosmwasm_schema::{cw_serde, generate_api};
50///
51/// #[cw_serde]
52/// struct InstantiateMsg;
53///
54/// #[cw_serde]
55/// struct MigrateMsg;
56///
57/// let api = generate_api! {
58/// name: "cw20",
59/// instantiate: InstantiateMsg,
60/// migrate: MigrateMsg,
61/// }.render();
62/// ```
63pub use cosmwasm_schema_derive::generate_api;
64/// Takes care of generating the interface description file for a contract. The body describes
65/// the message types included and allows setting contract name and version overrides.
66///
67/// The only obligatory field is `instantiate` - to set the InstantiateMsg type.
68///
69/// # Available fields
70/// - `name` - contract name, crate name by default
71/// - `version` - contract version, crate version by default
72/// - `instantiate` - instantiate msg type
73/// - `query` - query msg type, empty by default
74/// - `execute` - execute msg type, empty by default
75/// - `migrate` - migrate msg type, empty by default
76/// - `sudo` - sudo msg type, empty by default
77///
78/// # Example
79/// ```
80/// use cosmwasm_schema::{cw_serde, write_api};
81///
82/// #[cw_serde]
83/// struct InstantiateMsg;
84///
85/// #[cw_serde]
86/// struct MigrateMsg;
87///
88/// write_api! {
89/// name: "cw20",
90/// instantiate: InstantiateMsg,
91/// migrate: MigrateMsg,
92/// };
93/// ```
94pub use cosmwasm_schema_derive::write_api;
95
96// For use in macro expansions
97pub use schemars;
98pub use serde;