cosmwasm_schema/
lib.rs

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