{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "array",
    "items": {
        "oneOf": [
            {
                "type": "object",
                "additionalProperties": false,
                "minProperties": 1,
                "patternProperties": {
                    "^info\\.[a-zA-Z_]\\w*": {
                        "type": "object",
                        "description": "Information about the API.",
                        "additionalProperties": false
                    }
                },
                "properties": {
                    "///": {
                        "anyOf": [{ "type": "string" }, { "type": "array", "items": { "type": "string" } }]
                    }
                }
            },
            {
                "type": "object",
                "additionalProperties": false,
                "minProperties": 1,
                "patternProperties": {
                    "^struct\\.[a-zA-Z_]\\w*?": {
                        "type": "object",
                        "description": "A struct with 0 or more fields.",
                        "additionalProperties": false,
                        "patternProperties": {
                            "^[a-z]\\w*!?$": {
                                "$ref": "#/$defs/typeDeclaration"
                            }
                        }
                    }
                },
                "properties": {
                    "///": {
                        "anyOf": [{ "type": "string" }, { "type": "array", "items": { "type": "string" } }]
                    }
                }
            },
            {
                "type": "object",
                "additionalProperties": false,
                "minProperties": 1,
                "patternProperties": {
                    "union\\.[a-zA-Z_]\\w*$": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "description": "An union with 1 or more fields huzzah.",
                            "minProperties": 1,
                            "patternProperties": {
                                "^[A-Z]\\w*?$": {
                                    "type": "object",
                                    "additionalProperties": false,
                                    "patternProperties": {
                                        "^[a-z]\\w*!?$": {
                                            "$ref": "#/$defs/typeDeclaration"
                                        }
                                    }
                                }
                            },
                            "properties": {
                                "///": {
                                    "anyOf": [{ "type": "string" }, { "type": "array", "items": { "type": "string" } }]
                                }
                            }
                        }
                    }
                },
                "properties": {
                    "///": {
                        "anyOf": [{ "type": "string" }, { "type": "array", "items": { "type": "string" } }]
                    }
                }
            },
            {
                "type": "object",
                "additionalProperties": false,
                "minProperties": 2,
                "patternProperties": {
                    "^fn\\.[a-zA-Z_]\\w*": {
                        "description": "A function that accepts an argument struct and returns a result union that is either an `Ok_` struct or an error struct.",
                        "type": "object",
                        "additionalProperties": false,
                        "patternProperties": {
                            "^[a-z]\\w*!?$": {
                                "$ref": "#/$defs/typeDeclaration"
                            }
                        }
                    }
                },
                "required": ["->"],
                "properties": {
                    "->": {
                        "type": "array",
                        "prefixItems": [
                            {
                                "type": "object",
                                "required": ["Ok_"],
                                "properties": {
                                    "Ok_": {
                                        "type": "object",
                                        "additionalProperties": false,
                                        "patternProperties": {
                                            "^[a-z]\\w*!?$": {
                                                "$ref": "#/$defs/typeDeclaration"
                                            }
                                        }
                                    }
                                },
                                "additionalProperties": false
                            }
                        ],
                        "items": {
                            "type": "object",
                            "patternProperties": {
                                "^[A-Z]\\w*?$": {
                                    "type": "object",
                                    "additionalProperties": false,
                                    "patternProperties": {
                                        "^[a-z]\\w*!?$": {
                                            "$ref": "#/$defs/typeDeclaration"
                                        }
                                    },
                                    "properties": {
                                        "///": {
                                            "anyOf": [
                                                { "type": "string" },
                                                { "type": "array", "items": { "type": "string" } }
                                            ]
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "///": {
                        "anyOf": [{ "type": "string" }, { "type": "array", "items": { "type": "string" } }]
                    }
                }
            },
            {
                "type": "object",
                "additionalProperties": false,
                "minProperties": 2,
                "patternProperties": {
                    "^headers\\.[a-zA-Z_]\\w*": {
                        "description": "A function that accepts an argument struct and returns a result union that is either an `Ok_` struct or an error struct.",
                        "type": "object",
                        "additionalProperties": false,
                        "patternProperties": {
                            "^@[a-z]\\w*!?$": {
                                "$ref": "#/$defs/typeDeclaration"
                            }
                        }
                    }
                },
                "required": ["->"],
                "properties": {
                    "->": {
                        "type": "object",
                        "additionalProperties": false,
                        "patternProperties": {
                            "^@[a-z]\\w*!?$": {
                                "$ref": "#/$defs/typeDeclaration"
                            }
                        }
                    },
                    "///": {
                        "anyOf": [{ "type": "string" }, { "type": "array", "items": { "type": "string" } }]
                    }
                }
            },
            {
                "type": "object",
                "additionalProperties": false,
                "minProperties": 1,
                "patternProperties": {
                    "^errors\\.[a-zA-Z_]\\w*": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "description": "An union with 1 or more fields huzzah.",
                            "minProperties": 1,
                            "patternProperties": {
                                "^[A-Z]\\w*?$": {
                                    "type": "object",
                                    "additionalProperties": false,
                                    "patternProperties": {
                                        "^[a-z]\\w*!?$": {
                                            "$ref": "#/$defs/typeDeclaration"
                                        }
                                    }
                                }
                            },
                            "properties": {
                                "///": {
                                    "anyOf": [{ "type": "string" }, { "type": "array", "items": { "type": "string" } }]
                                }
                            }
                        }
                    }
                },
                "properties": {
                    "///": {
                        "anyOf": [{ "type": "string" }, { "type": "array", "items": { "type": "string" } }]
                    }
                }
            }
        ]
    },
    "$defs": {
        "typeDeclaration": {
            "oneOf": [
                {
                    "type": "string",
                    "pattern": "^((boolean|integer|number|string|any|bytes)|(fn|union|struct)\\.([a-zA-Z_]\\w*))(\\?)?$"
                },
                {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 1,
                    "items": {
                        "$ref": "#/$defs/typeDeclaration"
                    }
                },
                {
                    "type": "object",
                    "properties": {
                        "string": {
                            "$ref": "#/$defs/typeDeclaration"
                        }
                    },
                    "required": ["string"],
                    "additionalProperties": false
                }
            ]
        }
    }
}
