---
source: packages/cw-schema/tests/basic.rs
assertion_line: 12
expression: schema
---
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Schema",
  "oneOf": [
    {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "const": "v1"
        }
      },
      "$ref": "#/$defs/SchemaV1",
      "required": [
        "type"
      ]
    }
  ],
  "$defs": {
    "EnumCase": {
      "type": "object",
      "properties": {
        "description": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "const": "unit"
            }
          },
          "required": [
            "type"
          ]
        },
        {
          "type": "object",
          "properties": {
            "properties": {
              "type": "object",
              "additionalProperties": {
                "$ref": "#/$defs/StructProperty"
              }
            },
            "type": {
              "type": "string",
              "const": "named"
            }
          },
          "required": [
            "type",
            "properties"
          ]
        },
        {
          "type": "object",
          "properties": {
            "items": {
              "type": "array",
              "items": {
                "type": "integer",
                "format": "uint",
                "minimum": 0
              }
            },
            "type": {
              "type": "string",
              "const": "tuple"
            }
          },
          "required": [
            "type",
            "items"
          ]
        }
      ]
    },
    "MapKind": {
      "type": "string",
      "enum": [
        "bTree",
        "hash"
      ]
    },
    "Node": {
      "type": "object",
      "properties": {
        "description": {
          "type": [
            "string",
            "null"
          ]
        },
        "name": {
          "type": "string"
        }
      },
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "const": "float"
            }
          },
          "required": [
            "type"
          ]
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "const": "double"
            }
          },
          "required": [
            "type"
          ]
        },
        {
          "type": "object",
          "properties": {
            "precision": {
              "type": "integer",
              "format": "uint64",
              "minimum": 0
            },
            "signed": {
              "type": "boolean"
            },
            "type": {
              "type": "string",
              "const": "decimal"
            }
          },
          "required": [
            "type",
            "precision",
            "signed"
          ]
        },
        {
          "type": "object",
          "properties": {
            "precision": {
              "type": "integer",
              "format": "uint64",
              "minimum": 0
            },
            "signed": {
              "type": "boolean"
            },
            "type": {
              "type": "string",
              "const": "integer"
            }
          },
          "required": [
            "type",
            "precision",
            "signed"
          ]
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "const": "address"
            }
          },
          "required": [
            "type"
          ]
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "const": "binary"
            }
          },
          "required": [
            "type"
          ]
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "const": "checksum"
            }
          },
          "required": [
            "type"
          ]
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "const": "hexBinary"
            }
          },
          "required": [
            "type"
          ]
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "const": "timestamp"
            }
          },
          "required": [
            "type"
          ]
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "const": "string"
            }
          },
          "required": [
            "type"
          ]
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "const": "boolean"
            }
          },
          "required": [
            "type"
          ]
        },
        {
          "type": "object",
          "properties": {
            "items": {
              "type": "integer",
              "format": "uint",
              "minimum": 0
            },
            "type": {
              "type": "string",
              "const": "array"
            }
          },
          "required": [
            "type",
            "items"
          ]
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "const": "struct"
            }
          },
          "$ref": "#/$defs/StructType",
          "required": [
            "type"
          ]
        },
        {
          "type": "object",
          "properties": {
            "items": {
              "type": "array",
              "items": {
                "type": "integer",
                "format": "uint",
                "minimum": 0
              }
            },
            "type": {
              "type": "string",
              "const": "tuple"
            }
          },
          "required": [
            "type",
            "items"
          ]
        },
        {
          "type": "object",
          "properties": {
            "cases": {
              "type": "object",
              "additionalProperties": {
                "$ref": "#/$defs/EnumCase"
              }
            },
            "discriminator": {
              "type": [
                "string",
                "null"
              ]
            },
            "type": {
              "type": "string",
              "const": "enum"
            }
          },
          "required": [
            "type",
            "cases"
          ]
        },
        {
          "type": "object",
          "properties": {
            "key": {
              "type": "integer",
              "format": "uint",
              "minimum": 0
            },
            "kind": {
              "$ref": "#/$defs/MapKind"
            },
            "type": {
              "type": "string",
              "const": "map"
            },
            "value": {
              "type": "integer",
              "format": "uint",
              "minimum": 0
            }
          },
          "required": [
            "type",
            "kind",
            "key",
            "value"
          ]
        },
        {
          "type": "object",
          "properties": {
            "inner": {
              "type": "integer",
              "format": "uint",
              "minimum": 0
            },
            "type": {
              "type": "string",
              "const": "boxed"
            }
          },
          "required": [
            "type",
            "inner"
          ]
        },
        {
          "type": "object",
          "properties": {
            "inner": {
              "type": "integer",
              "format": "uint",
              "minimum": 0
            },
            "type": {
              "type": "string",
              "const": "optional"
            }
          },
          "required": [
            "type",
            "inner"
          ]
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "const": "unit"
            }
          },
          "required": [
            "type"
          ]
        }
      ],
      "required": [
        "name"
      ]
    },
    "SchemaV1": {
      "type": "object",
      "properties": {
        "definitions": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Node"
          }
        },
        "root": {
          "type": "integer",
          "format": "uint",
          "minimum": 0
        }
      },
      "required": [
        "root",
        "definitions"
      ]
    },
    "StructProperty": {
      "type": "object",
      "properties": {
        "defaulting": {
          "type": "boolean"
        },
        "description": {
          "type": [
            "string",
            "null"
          ]
        },
        "value": {
          "type": "integer",
          "format": "uint",
          "minimum": 0
        }
      },
      "required": [
        "value"
      ]
    },
    "StructType": {
      "anyOf": [
        {
          "type": "null"
        },
        {
          "type": "object",
          "properties": {
            "properties": {
              "type": "object",
              "additionalProperties": {
                "$ref": "#/$defs/StructProperty"
              }
            }
          },
          "required": [
            "properties"
          ]
        },
        {
          "type": "object",
          "properties": {
            "items": {
              "type": "array",
              "items": {
                "type": "integer",
                "format": "uint",
                "minimum": 0
              }
            }
          },
          "required": [
            "items"
          ]
        }
      ]
    }
  }
}
