{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://chefquiz.com/quiz-import/chefquiz.schema.json",
  "title": "chefquiz quiz import v1",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "format",
    "version",
    "quiz"
  ],
  "properties": {
    "format": {
      "const": "chefquiz"
    },
    "version": {
      "const": 1
    },
    "quiz": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "type"
      ],
      "properties": {
        "type": {
          "enum": [
            "personality",
            "trivia"
          ]
        },
        "title": {
          "type": "string",
          "maxLength": 150
        },
        "description": {
          "type": "string",
          "maxLength": 1000
        },
        "mood": {
          "enum": [
            "general",
            "psychology",
            "fun",
            "love",
            "technical",
            "action"
          ],
          "default": "general"
        },
        "category": {
          "type": "string",
          "maxLength": 60
        },
        "tags": {
          "type": "array",
          "maxItems": 10,
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 40
          }
        },
        "coverImage": {
          "type": "string",
          "maxLength": 2048,
          "description": "Optional direct HTTPS image URL or an existing /api/media/UUID path. Omit or leave blank to add visuals later."
        },
        "startButtonText": {
          "type": "string",
          "maxLength": 40
        },
        "results": {
          "type": "array",
          "maxItems": 12,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id"
            ],
            "properties": {
              "id": {
                "type": "string",
                "pattern": "^[a-zA-Z0-9_-]{1,80}$",
                "not": {
                  "enum": [
                    "__proto__",
                    "constructor",
                    "prototype"
                  ]
                }
              },
              "title": {
                "type": "string",
                "maxLength": 100
              },
              "description": {
                "type": "string",
                "maxLength": 1000
              },
              "emoji": {
                "type": "string",
                "maxLength": 20
              },
              "image": {
                "type": "string",
                "maxLength": 2048,
                "description": "Optional direct HTTPS image URL or an existing /api/media/UUID path. Omit or leave blank to add visuals later."
              }
            }
          }
        },
        "questions": {
          "type": "array",
          "maxItems": 30,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "answers"
            ],
            "properties": {
              "id": {
                "type": "string",
                "pattern": "^[a-zA-Z0-9_-]{1,80}$",
                "not": {
                  "enum": [
                    "__proto__",
                    "constructor",
                    "prototype"
                  ]
                }
              },
              "text": {
                "type": "string",
                "maxLength": 300
              },
              "image": {
                "type": "string",
                "maxLength": 2048,
                "description": "Optional direct HTTPS image URL or an existing /api/media/UUID path. Omit or leave blank to add visuals later."
              },
              "answerFormat": {
                "enum": [
                  "list",
                  "images"
                ],
                "default": "list"
              },
              "explanation": {
                "type": "string",
                "maxLength": 1000
              },
              "answers": {
                "type": "array",
                "minItems": 2,
                "maxItems": 6,
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "text": {
                      "type": "string",
                      "maxLength": 300
                    },
                    "image": {
                      "type": "string",
                      "maxLength": 2048,
                      "description": "Optional direct HTTPS image URL or an existing /api/media/UUID path. Omit or leave blank to add visuals later."
                    },
                    "weights": {
                      "type": "object",
                      "propertyNames": {
                        "type": "string",
                        "pattern": "^[a-zA-Z0-9_-]{1,80}$",
                        "not": {
                          "enum": [
                            "__proto__",
                            "constructor",
                            "prototype"
                          ]
                        }
                      },
                      "additionalProperties": {
                        "type": "number",
                        "minimum": 0,
                        "maximum": 10
                      }
                    },
                    "correct": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "type": {
                "const": "trivia"
              }
            }
          },
          "then": {
            "properties": {
              "questions": {
                "items": {
                  "properties": {
                    "answers": {
                      "contains": {
                        "required": [
                          "correct"
                        ],
                        "properties": {
                          "correct": {
                            "const": true
                          }
                        }
                      },
                      "minContains": 1,
                      "maxContains": 1,
                      "items": {
                        "not": {
                          "required": [
                            "weights"
                          ]
                        }
                      }
                    }
                  }
                }
              },
              "results": {
                "maxItems": 0
              }
            }
          },
          "else": {
            "properties": {
              "questions": {
                "items": {
                  "properties": {
                    "answers": {
                      "items": {
                        "not": {
                          "required": [
                            "correct"
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      ]
    }
  }
}
