{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/coderpad/json-schema/coderpad-question-list-schema.json",
  "title": "QuestionList",
  "x-generated": "2026-11-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/coderpad-organization-api-openapi.yml#/components/schemas/QuestionList",
  "allOf": [
    {
      "$ref": "#/$defs/PaginatedResponse"
    },
    {
      "type": "object",
      "required": [
        "questions"
      ],
      "properties": {
        "questions": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Question"
          }
        }
      }
    }
  ],
  "$defs": {
    "CandidateInstruction": {
      "type": "object",
      "required": [
        "instructions"
      ],
      "properties": {
        "instructions": {
          "type": "string",
          "description": "The instructions, in Markdown."
        },
        "name": {
          "type": "string",
          "description": "Name of this step, for multi-step instructions."
        },
        "default_visible": {
          "type": "boolean",
          "description": "Whether the candidate sees this step when the pad opens. The first step is always visible."
        }
      }
    },
    "FileContent": {
      "type": "object",
      "required": [
        "path"
      ],
      "properties": {
        "path": {
          "type": "string"
        },
        "contents": {
          "type": "string"
        },
        "hidden": {
          "type": "boolean",
          "description": "Hide the file from the candidate."
        }
      }
    },
    "Ok": {
      "type": "object",
      "required": [
        "status"
      ],
      "properties": {
        "status": {
          "type": "string",
          "enum": [
            "OK"
          ]
        }
      }
    },
    "PaginatedResponse": {
      "allOf": [
        {
          "$ref": "#/$defs/Ok"
        },
        {
          "type": "object",
          "required": [
            "total"
          ],
          "properties": {
            "next_page": {
              "type": "string",
              "format": "uri",
              "description": "URL of the next page. Absent on the last page."
            },
            "prev_page": {
              "type": "string",
              "format": "uri",
              "description": "URL of the previous page. Absent on the first page."
            },
            "total": {
              "type": "integer",
              "description": "Total number of items across all pages."
            }
          }
        }
      ]
    },
    "Question": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer"
        },
        "title": {
          "type": "string"
        },
        "owner_email": {
          "type": [
            "string",
            "null"
          ],
          "format": "email"
        },
        "language": {
          "type": [
            "string",
            "null"
          ],
          "description": "The question language, or the project template slug for project template questions, as accepted on creation. `null` for questions with variants."
        },
        "description": {
          "type": [
            "string",
            "null"
          ],
          "description": "Description of the question, only shown to interviewers."
        },
        "candidate_instructions": {
          "type": "array",
          "description": "Instructions shown to the candidate.",
          "items": {
            "$ref": "#/$defs/CandidateInstruction"
          }
        },
        "contents": {
          "type": [
            "string",
            "null"
          ],
          "description": "Starter code of single-file questions."
        },
        "shared": {
          "type": "boolean",
          "description": "Whether the question is shared with your organization."
        },
        "used": {
          "type": "integer",
          "description": "Number of pads the question was used in."
        },
        "take_home": {
          "type": "boolean"
        },
        "test_cases_enabled": {
          "type": "boolean"
        },
        "solution": {
          "type": [
            "string",
            "null"
          ]
        },
        "pad_type": {
          "$ref": "#/$defs/QuestionPadType"
        },
        "is_draft": {
          "type": "boolean"
        },
        "ai_assist_custom_system_prompt": {
          "type": "string",
          "description": "Custom AI Assist system prompt. Only present when set."
        },
        "author_name": {
          "type": [
            "string",
            "null"
          ]
        },
        "organization_name": {
          "type": [
            "string",
            "null"
          ]
        },
        "custom_database": {
          "type": "object",
          "description": "The custom database attached to the question, if any.",
          "properties": {
            "id": {
              "type": "integer"
            },
            "language": {
              "type": "string"
            },
            "title": {
              "type": "string"
            },
            "description": {
              "type": [
                "string",
                "null"
              ]
            },
            "schema": {
              "type": [
                "string",
                "null"
              ]
            },
            "schema_json": {
              "description": "The database schema, as JSON."
            }
          }
        },
        "custom_files": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "title": {
                "type": "string"
              },
              "description": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "filename": {
                "type": "string"
              },
              "filesize": {
                "type": "string",
                "description": "Human-readable file size."
              }
            }
          }
        },
        "question_variants": {
          "type": "array",
          "description": "Summary of the question's variants. See `GET /questions/{question_id}/variants` for their code.",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "integer"
              },
              "language": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "project_template_id": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "project_template_slug": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "display": {
                "type": "string"
              }
            }
          }
        },
        "public_take_home_setting_id": {
          "type": [
            "integer",
            "null"
          ],
          "description": "Only present when `test_cases_enabled` is `true`."
        },
        "contents_for_test_cases": {
          "type": "string",
          "description": "Starter code generated from the test cases. Only present when `test_cases_enabled` is `true`."
        },
        "test_cases": {
          "type": "array",
          "description": "Only present when `test_cases_enabled` is `true`.",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "integer"
              },
              "return_value": {
                "description": "The expected return value of the test case."
              },
              "visible": {
                "type": "boolean"
              },
              "arguments": {
                "type": "array",
                "items": {}
              }
            }
          }
        },
        "file_contents": {
          "type": "array",
          "description": "Files of HTML and project template questions. For a project template question, each template file the question removed is listed with `\"deleted\": true`, and the list is empty when the question opens with the unmodified template files.\n",
          "items": {
            "allOf": [
              {
                "$ref": "#/$defs/FileContent"
              },
              {
                "type": "object",
                "properties": {
                  "deleted": {
                    "type": "boolean"
                  }
                }
              }
            ]
          }
        },
        "created_at": {
          "$ref": "#/$defs/Timestamp"
        },
        "updated_at": {
          "$ref": "#/$defs/Timestamp"
        }
      }
    },
    "QuestionPadType": {
      "type": "string",
      "description": "The type of pads a question can be used in.",
      "enum": [
        "any",
        "live",
        "take_home"
      ]
    },
    "Timestamp": {
      "type": "string",
      "format": "date-time"
    }
  }
}