{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/monacloud/main/json-schema/monacloud-app-create-request-schema.json",
  "title": "AppCreateRequest",
  "description": "source=git dùng repo_url public HTTPS. source=upload không cần repo_url, tạo app awaiting_upload rồi POST /api/apps/{app_id}/upload. Không có source giữ luồng git tương thích.",
  "x-generated": "2026-10-18",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/monacloud-vn-openapi.json#/components/schemas/AppCreateRequest",
  "properties": {
    "source": {
      "type": "string",
      "enum": [
        "git",
        "upload"
      ],
      "description": "git cho repo public; upload cho archive local, không cần repo_url."
    },
    "repo_url": {
      "type": "string",
      "maxLength": 2048,
      "title": "Repo Url",
      "description": "Bắt buộc với nguồn git (kể cả khi bỏ qua source); không cần với source=upload."
    },
    "branch": {
      "type": "string",
      "maxLength": 255,
      "minLength": 1,
      "title": "Branch",
      "default": "main"
    },
    "build_type": {
      "type": "string",
      "enum": [
        "dockerfile",
        "nixpacks",
        "static"
      ],
      "title": "Build Type",
      "default": "dockerfile"
    },
    "dockerfile": {
      "type": "string",
      "maxLength": 255,
      "minLength": 1,
      "title": "Dockerfile",
      "default": "Dockerfile"
    },
    "env": {
      "additionalProperties": {
        "type": "string"
      },
      "type": "object",
      "title": "Env"
    },
    "domain": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Domain"
    },
    "app_host_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "App Host Id"
    },
    "port": {
      "type": "integer",
      "maximum": 65535,
      "minimum": 1,
      "title": "Port",
      "default": 3000
    }
  },
  "type": "object",
  "allOf": [
    {
      "if": {
        "properties": {
          "source": {
            "const": "upload"
          }
        },
        "required": [
          "source"
        ]
      },
      "else": {
        "required": [
          "repo_url"
        ]
      }
    }
  ]
}