{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "flags": {
      "properties": {
        "allowLegacyBlob": {
          "default": false,
          "description": "Accept blobs with a cid field.",
          "type": "boolean"
        },
        "allowLenientDatetime": {
          "default": false,
          "description": "Accept datetimes beyond strict RFC 3339.",
          "type": "boolean"
        },
        "skipExternalRefs": {
          "default": false,
          "description": "Count references that are neither pasted nor indexed as valid.",
          "type": "boolean"
        }
      },
      "type": "object"
    },
    "main": {
      "description": "Validate a set of lexicon schemas and check records against the first one. References resolve in order from the same schema, the other pasted schemas, then lexicons Lexicon Garden has indexed. At most 50 schemas, 100 records and 1 MiB of body.",
      "errors": [
        {
          "description": "Too many schemas or records, or none.",
          "name": "InvalidRequest"
        }
      ],
      "input": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "flags": {
              "ref": "#flags",
              "type": "ref"
            },
            "records": {
              "description": "Records to check against the first schema's main record.",
              "items": {
                "type": "unknown"
              },
              "maxLength": 100,
              "type": "array"
            },
            "schemas": {
              "description": "Lexicon documents. Records are checked against the first; the rest resolve its references.",
              "items": {
                "type": "unknown"
              },
              "maxLength": 50,
              "minLength": 1,
              "type": "array"
            }
          },
          "required": [
            "schemas"
          ],
          "type": "object"
        }
      },
      "output": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "records": {
              "items": {
                "ref": "#recordResult",
                "type": "ref"
              },
              "type": "array"
            },
            "references": {
              "items": {
                "ref": "#referenceResult",
                "type": "ref"
              },
              "type": "array"
            },
            "schemas": {
              "items": {
                "ref": "#schemaResult",
                "type": "ref"
              },
              "type": "array"
            }
          },
          "required": [
            "schemas",
            "references",
            "records"
          ],
          "type": "object"
        }
      },
      "type": "procedure"
    },
    "recordError": {
      "properties": {
        "message": {
          "maxLength": 2000,
          "type": "string"
        },
        "path": {
          "maxLength": 1024,
          "type": "string"
        }
      },
      "required": [
        "path",
        "message"
      ],
      "type": "object"
    },
    "recordResult": {
      "properties": {
        "errors": {
          "items": {
            "ref": "#recordError",
            "type": "ref"
          },
          "type": "array"
        },
        "index": {
          "minimum": 0,
          "type": "integer"
        },
        "type": {
          "maxLength": 512,
          "type": "string"
        },
        "valid": {
          "type": "boolean"
        }
      },
      "required": [
        "index",
        "valid",
        "errors"
      ],
      "type": "object"
    },
    "referenceResult": {
      "properties": {
        "ref": {
          "description": "The full nsid#def form, or the NSID alone for a main definition.",
          "maxLength": 512,
          "type": "string"
        },
        "source": {
          "knownValues": [
            "this-schema",
            "pasted",
            "index",
            "unresolved",
            "skipped"
          ],
          "type": "string"
        }
      },
      "required": [
        "ref",
        "source"
      ],
      "type": "object"
    },
    "schemaResult": {
      "properties": {
        "defCount": {
          "minimum": 0,
          "type": "integer"
        },
        "id": {
          "format": "nsid",
          "type": "string"
        },
        "index": {
          "minimum": 0,
          "type": "integer"
        },
        "issues": {
          "items": {
            "maxLength": 2000,
            "type": "string"
          },
          "type": "array"
        },
        "mainType": {
          "maxLength": 32,
          "type": "string"
        },
        "valid": {
          "type": "boolean"
        }
      },
      "required": [
        "index",
        "defCount",
        "valid",
        "issues"
      ],
      "type": "object"
    }
  },
  "id": "garden.lexicon.validateSet",
  "lexicon": 1
}
