Skip to content

Commit

Permalink
cw1-whitelist-ng: Schema generation
Browse files Browse the repository at this point in the history
  • Loading branch information
hashedone committed Oct 20, 2021
1 parent 9fe77de commit 5aee758
Show file tree
Hide file tree
Showing 6 changed files with 1,091 additions and 0 deletions.
6 changes: 6 additions & 0 deletions contracts/cw1-whitelist-ng/.cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[alias]
wasm = "build --release --target wasm32-unknown-unknown"
wasm-debug = "build --target wasm32-unknown-unknown"
unit-test = "test --lib"
integration-test = "test --test integration"
schema = "run --example schema"
18 changes: 18 additions & 0 deletions contracts/cw1-whitelist-ng/examples/schema.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use std::env::current_dir;
use std::fs::create_dir_all;

use cosmwasm_schema::{export_schema, export_schema_with_title, remove_schemas, schema_for};

use cw1_whitelist_ng::msg::{AdminListResponse, ExecuteMsg, InstantiateMsg, QueryMsg};

fn main() {
let mut out_dir = current_dir().unwrap();
out_dir.push("schema");
create_dir_all(&out_dir).unwrap();
remove_schemas(&out_dir).unwrap();

export_schema(&schema_for!(InstantiateMsg), &out_dir);
export_schema_with_title(&schema_for!(ExecuteMsg), &out_dir, "ExecuteMsg");
export_schema_with_title(&schema_for!(QueryMsg), &out_dir, "QueryMsg");
export_schema(&schema_for!(AdminListResponse), &out_dir);
}
20 changes: 20 additions & 0 deletions contracts/cw1-whitelist-ng/schema/admin_list_response.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "AdminListResponse",
"type": "object",
"required": [
"admins",
"mutable"
],
"properties": {
"admins": {
"type": "array",
"items": {
"type": "string"
}
},
"mutable": {
"type": "boolean"
}
}
}

0 comments on commit 5aee758

Please sign in to comment.