---
# System prepended metadata

title: JSON Schema message specification

---

## Instatiate
- Expose `instatiate` field
- No response schema
- non-nullable

## Migrate
- nullable
- No response schema

## Sudo
- I don't care about it

## Execute
- nullable
- no response schema

### To modify the input schema for `execute` case:

1. Convert the `one-of` array to an array of each message.
2. Add $schema to each schema
3. Additionally, include an object named definitions in each message.


#### From
```json
"execute": {
    "$schema": "http://json-schema.org/draft-07/schema#",
    "title": "ExecuteMsg",
    "oneOf": [
      {
        "description": "Set address",
        "type": "object",
        "required": [
          "set_address"
        ],
        "properties": {
          "set_address": {
            "type": "object",
            "required": [
              "address",
              "address_type"
            ],
            "properties": {
              "address": {
                "type": "string"
              },
              "address_type": {
                "$ref": "#/definitions/MarsAddressType"
              }
            },
            "additionalProperties": false
          }
        },
        "additionalProperties": false
      },
      {
        "description": "Manages admin role state",
        "type": "object",
        "required": [
          "update_owner"
        ],
        "properties": {
          "update_owner": {
            "$ref": "#/definitions/OwnerUpdate"
          }
        },
        "additionalProperties": false
      }
    ],
  }
```

#### To this
```jsonld
[
    {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "description": "Set address",
        "type": "object",
        "required": [
          "set_address"
        ],
        "properties": {
          "set_address": {
            "type": "object",
            "required": [
              "address",
              "address_type"
            ],
            "properties": {
              "address": {
                "type": "string"
              },
              "address_type": {
                "$ref": "#/definitions/MarsAddressType"
              }
            },
            "additionalProperties": false
          }
        },
        "additionalProperties": false,
        "definitions": {...},
    },
    {
        "description": "Manages admin role state",
        "type": "object",
        "required": [
          "update_owner"
        ],
        "properties": {
          "update_owner": {
            "$ref": "#/definitions/OwnerUpdate"
          }
        },
        "additionalProperties": false,
        "definitions": {...},
    }
]
```


## Query
- nullable
- response schema


### To modify the input and response schemas for `query` case:

1. Convert the `one-of` array to an array of each message.
2. Additionally, include an object named definitions in each message.
3. Clone the specific property of response that matches with query's input.
4. Add `readOnly` property to all response schema

#### From
```json
{
    "query": {
    "$schema": "http://json-schema.org/draft-07/schema#",
    "title": "QueryMsg",
    "oneOf": [
      {
        "description": "Get config",
        "type": "object",
        "required": [
          "config"
        ],
        "properties": {
          "config": {
            "type": "object",
            "additionalProperties": false
          }
        },
        "additionalProperties": false
      },
      {
        "description": "Get a single address",
        "type": "object",
        "required": [
          "address"
        ],
        "properties": {
          "address": {
            "$ref": "#/definitions/MarsAddressType"
          }
        },
        "additionalProperties": false
      },
      {
        "description": "Get a list of addresses",
        "type": "object",
        "required": [
          "addresses"
        ],
        "properties": {
          "addresses": {
            "type": "array",
            "items": {
              "$ref": "#/definitions/MarsAddressType"
            }
          }
        },
        "additionalProperties": false
      },
      {
        "description": "Query all stored addresses with pagination",
        "type": "object",
        "required": [
          "all_addresses"
        ],
        "properties": {
          "all_addresses": {
            "type": "object",
            "properties": {
              "limit": {
                "type": [
                  "integer",
                  "null"
                ],
                "format": "uint32",
                "minimum": 0.0
              },
              "start_after": {
                "anyOf": [
                  {
                    "$ref": "#/definitions/MarsAddressType"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            },
            "additionalProperties": false
          }
        },
        "additionalProperties": false
      }
    ],
    "definitions": {
      ...
    }
  },
}
```

to this in TypeScript

```typescript
// Array<[InputSchema, ResponseSchema]>
[    
    // tuple
    [
        // input
        {
            "$schema": "http://json-schema.org/draft-07/schema#",
            "description": "Get config",
            "type": "object",
            "required": [
              "config"
            ],
            "properties": {
              "config": {
                "type": "object",
                "additionalProperties": false
              }
            },
            "additionalProperties": false,
            "definitions": {...}
        },
        {
          "$schema": "http://json-schema.org/draft-07/schema#",
          "title": "ConfigResponse",
          "type": "object",
          "required": [
            "prefix"
          ],
          "properties": {
            "owner": {
              "description": "The contract's owner",
              "type": [
                "string",
                "null"
              ]
            },
            "prefix": {
              "description": "The address prefix of the chain this contract is deployed on",
              "type": "string"
            },
            "proposed_new_owner": {
              "description": "The contract's proposed owner",
              "type": [
                "string",
                "null"
              ]
            }
          },
          "additionalProperties": false,
          "definitions": {...},
          "readOnly": true,
        }
    ]
]
```