{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://json.schemastore.org/aspire-8.0.json",
  "type": "object",
  "description": "Defines the .NET Aspire 8.0 deployment manifest JSON schema.",
  "required": ["resources"],
  "properties": {
    "resources": {
      "type": "object",
      "description": "Contains the set of resources deployable as part of this manifest. Each property is a distinct resource.",
      "additionalProperties": {
        "type": "object",
        "required": ["type"],
        "properties": {
          "type": {
            "type": "string"
          }
        },
        "oneOf": [
          {
            "type": "object",
            "description": "A resource that represents a Dockerfile that will be built into a container during deployment.",
            "required": ["type", "path", "context"],
            "properties": {
              "type": {
                "const": "dockerfile.v0"
              },
              "path": {
                "type": "string",
                "description": "The file path to the Dockerfile to be built into a container image."
              },
              "context": {
                "type": "string",
                "description": "A directory path used as the context for building the Dockerfile into a container image."
              },
              "env": {
                "$ref": "#/definitions/env"
              },
              "bindings": {
                "$ref": "#/definitions/bindings"
              },
              "buildArgs": {
                "$ref": "#/definitions/buildArgs"
              }
            },
            "additionalProperties": false
          },
          {
            "type": "object",
            "description": "A generic container resource.",
            "required": ["type", "image"],
            "properties": {
              "type": {
                "const": "container.v0"
              },
              "image": {
                "type": "string",
                "description": "A string representing the container image to be used."
              },
              "entrypoint": {
                "type": "string",
                "description": "The entrypoint to use for the container image when executed."
              },
              "args": {
                "$ref": "#/definitions/args"
              },
              "connectionString": {
                "$ref": "#/definitions/connectionString"
              },
              "env": {
                "$ref": "#/definitions/env"
              },
              "bindings": {
                "$ref": "#/definitions/bindings"
              },
              "bindMounts": {
                "$ref": "#/definitions/bindMounts"
              },
              "volumes": {
                "$ref": "#/definitions/volumes"
              },
              "build": false
            },
            "additionalProperties": false
          },
          {
            "type": "object",
            "description": "A generic container resource.",
            "oneOf": [
              {
                "required": ["type", "build"]
              },
              {
                "required": ["type", "image"]
              }
            ],
            "properties": {
              "type": {
                "const": "container.v1"
              },
              "image": {
                "type": "string",
                "description": "A string representing the container image to be used."
              },
              "entrypoint": {
                "type": "string",
                "description": "The entrypoint to use for the container image when executed."
              },
              "deployment": {
                "oneOf": [
                  {
                    "$ref": "#/definitions/resource.azure.bicep.v0"
                  },
                  {
                    "$ref": "#/definitions/resource.azure.bicep.v1"
                  }
                ]
              },
              "args": {
                "$ref": "#/definitions/args"
              },
              "build": {
                "$ref": "#/definitions/build"
              },
              "connectionString": {
                "$ref": "#/definitions/connectionString"
              },
              "env": {
                "$ref": "#/definitions/env"
              },
              "bindings": {
                "$ref": "#/definitions/bindings"
              },
              "bindMounts": {
                "$ref": "#/definitions/bindMounts"
              },
              "volumes": {
                "$ref": "#/definitions/volumes"
              }
            },
            "additionalProperties": false
          },
          {
            "type": "object",
            "description": "Represents a .NET project resource.",
            "required": ["type", "path"],
            "properties": {
              "type": {
                "const": "project.v0"
              },
              "path": {
                "type": "string",
                "description": "The path to the project file. Relative paths are interpreted as being relative to the location of the manifest file."
              },
              "args": {
                "$ref": "#/definitions/args"
              },
              "env": {
                "$ref": "#/definitions/env"
              },
              "bindings": {
                "$ref": "#/definitions/bindings"
              }
            },
            "additionalProperties": false
          },
          {
            "type": "object",
            "description": "Represents a .NET project resource.",
            "required": ["type", "path"],
            "properties": {
              "type": {
                "const": "project.v1"
              },
              "path": {
                "type": "string",
                "description": "The path to the project file. Relative paths are interpreted as being relative to the location of the manifest file."
              },
              "deployment": {
                "oneOf": [
                  {
                    "$ref": "#/definitions/resource.azure.bicep.v0"
                  },
                  {
                    "$ref": "#/definitions/resource.azure.bicep.v1"
                  }
                ]
              },
              "args": {
                "$ref": "#/definitions/args"
              },
              "env": {
                "$ref": "#/definitions/env"
              },
              "bindings": {
                "$ref": "#/definitions/bindings"
              }
            },
            "additionalProperties": false
          },
          {
            "type": "object",
            "description": "Represents an executable resource.",
            "required": ["type", "command", "workingDirectory"],
            "properties": {
              "type": {
                "const": "executable.v0"
              },
              "workingDirectory": {
                "type": "string",
                "description": "The path to the working directory. Should be interpreted as being relative to the AppHost directory."
              },
              "command": {
                "type": "string",
                "description": "The path to the command. Should be interpreted as being relative to the AppHost directory."
              },
              "args": {
                "$ref": "#/definitions/args"
              },
              "env": {
                "$ref": "#/definitions/env"
              },
              "bindings": {
                "$ref": "#/definitions/bindings"
              }
            },
            "additionalProperties": false
          },
          {
            "type": "object",
            "required": ["connectionString"],
            "description": "Represents a value resource. Typically used to perform string concatenation (e.g. for connection strings).",
            "properties": {
              "type": {
                "const": "value.v0"
              },
              "connectionString": {
                "$ref": "#/definitions/connectionString"
              }
            },
            "additionalProperties": false
          },
          {
            "type": "object",
            "description": "Represents a parameter resource. Parameter resources are used to represent external configuration values that should be provided at deployment time.",
            "required": ["value", "inputs"],
            "properties": {
              "type": {
                "const": "parameter.v0"
              },
              "value": {
                "$ref": "#/definitions/value"
              },
              "connectionString": {
                "$ref": "#/definitions/connectionString"
              },
              "inputs": {
                "type": "object",
                "description": "Defines a set of input values which need to be either generated or prompted by the deployment tool. This is typically used for environment specific configuration values or secrets.",
                "additionalProperties": {
                  "type": "object",
                  "required": ["type"],
                  "properties": {
                    "type": {
                      "type": "string",
                      "description": "The type of the value to be prompted or generated. Currently only 'string'' is supported.",
                      "enum": ["string"]
                    },
                    "secret": {
                      "type": "boolean",
                      "description": "Flag indicating whether the value should be treated as a secret. Deployment tools should note this value to take appropriate precautions when prompting, storing, and transmitting this value."
                    },
                    "default": {
                      "type": "object",
                      "oneOf": [
                        {
                          "required": ["generate"],
                          "properties": {
                            "generate": {
                              "type": "object",
                              "required": ["minLength"],
                              "properties": {
                                "minLength": {
                                  "type": "number",
                                  "description": "The minimum length of the generated value."
                                },
                                "lower": {
                                  "type": "boolean",
                                  "description": "Indicates whether lower case characters are allowed in the generated value."
                                },
                                "upper": {
                                  "type": "boolean",
                                  "description": "Indicates whether upper case characters are allowed in the generated value."
                                },
                                "numeric": {
                                  "type": "boolean",
                                  "description": "Indicates whether numeric characters are allowed in the generated value."
                                },
                                "special": {
                                  "type": "boolean",
                                  "description": "Indicates whether special characters are allowed in the generated value."
                                },
                                "minLower": {
                                  "type": "number",
                                  "description": "Specifies the minimum number of lower case characters that must appear in the generated value."
                                },
                                "minUpper": {
                                  "type": "number",
                                  "description": "Specifies the minimum number of upper case characters that must appear in the generated value."
                                },
                                "minNumeric": {
                                  "type": "number",
                                  "description": "Specifies the minimum number of numeric characters that must appear in the generated value."
                                },
                                "minSpecial": {
                                  "type": "number",
                                  "description": "Specifies the minimum number of special characters that must appear in the generated value."
                                }
                              }
                            },
                            "additionalProperties": false
                          }
                        },
                        {
                          "required": ["value"],
                          "properties": {
                            "value": {
                              "type": "string",
                              "description": "The default value to use if the parameter is not provided at deployment time."
                            }
                          }
                        }
                      ]
                    }
                  },
                  "additionalProperties": false
                }
              }
            },
            "additionalProperties": false
          },
          {
            "type": "object",
            "description": "Represents a formatted projection of a parameter value, produced by applying the specified filter to the parameter.",
            "required": ["type", "value", "filter"],
            "properties": {
              "type": {
                "const": "annotated.string"
              },
              "value": {
                "$ref": "#/definitions/value"
              },
              "filter": {
                "$ref": "#/definitions/annotatedStringFilter"
              }
            },
            "additionalProperties": false
          },
          {
            "type": "object",
            "description": "Represents a Dapr resource in the manifest.",
            "required": ["dapr"],
            "properties": {
              "type": {
                "const": "dapr.v0"
              },
              "dapr": {
                "type": "object",
                "description": "Dapr specific configuration.",
                "required": ["application", "appId", "components"],
                "properties": {
                  "application": {
                    "type": "string"
                  },
                  "appId": {
                    "type": "string"
                  },
                  "components": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                },
                "additionalProperties": false
              }
            },
            "additionalProperties": false
          },
          {
            "type": "object",
            "required": ["daprComponent"],
            "properties": {
              "type": {
                "const": "dapr.component.v0"
              },
              "daprComponent": {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string"
                  }
                },
                "additionalProperties": false
              }
            },
            "additionalProperties": false
          },
          {
            "$ref": "#/definitions/resource.azure.bicep.v0"
          },
          {
            "$ref": "#/definitions/resource.azure.bicep.v1"
          },
          {
            "type": "object",
            "required": ["type", "stack-name"],
            "properties": {
              "type": {
                "const": "aws.cloudformation.stack.v0"
              },
              "stack-name": {
                "type": "string"
              },
              "references": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "target-resource": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": false
                }
              }
            },
            "additionalProperties": false
          },
          {
            "type": "object",
            "required": ["type", "stack-name", "template-path"],
            "properties": {
              "type": {
                "const": "aws.cloudformation.template.v0"
              },
              "stack-name": {
                "type": "string"
              },
              "template-path": {
                "type": "string"
              },
              "references": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "target-resource": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": false
                }
              }
            },
            "additionalProperties": false
          },
          {
            "type": "object",
            "description": "Represents extensions. Any object with a 'type' field that is not captured above will pass.",
            "required": ["type"],
            "not": {
              "properties": {
                "type": {
                  "type": "string",
                  "enum": [
                    "parameter.v0",
                    "annotated.string",
                    "container.v0",
                    "container.v1",
                    "dockerfile.v0",
                    "project.v0",
                    "project.v1",
                    "value.v0",
                    "executable.v0",
                    "azure.bicep.v0",
                    "azure.bicep.v1",
                    "aws.cloudformation.template.v0",
                    "aws.cloudformation.stack.v0",
                    "dapr.component.v0",
                    "dapr.v0"
                  ]
                }
              }
            },
            "properties": {
              "type": {
                "type": "string"
              }
            }
          }
        ]
      }
    }
  },
  "definitions": {
    "resource.azure.bicep.v0": {
      "type": "object",
      "description": "Represents a resource that is deployed using Azure Bicep.",
      "required": ["path"],
      "properties": {
        "type": {
          "const": "azure.bicep.v0"
        },
        "path": {
          "type": "string",
          "description": "Path to the Bicep file to be used for deployment."
        },
        "connectionString": {
          "$ref": "#/definitions/connectionString"
        },
        "params": {
          "type": "object",
          "description": "A list of parameters which are passed to Azure deployment.",
          "additionalProperties": {
            "oneOf": [
              { "type": "array" },
              { "type": "boolean" },
              { "type": "number" },
              { "type": "object" },
              { "type": "string" }
            ]
          }
        }
      },
      "additionalProperties": false
    },
    "resource.azure.bicep.v1": {
      "allOf": [
        {
          "$ref": "#/definitions/resource.azure.bicep.v0"
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "const": "azure.bicep.v1"
            },
            "scope": {
              "type": "object",
              "properties": {
                "resourceGroup": {
                  "type": "string",
                  "description": "The name of the resource group to deploy the resource to."
                }
              }
            }
          }
        }
      ]
    },
    "connectionString": {
      "type": "string",
      "description": "A connection string that can be used to connect to this resource."
    },
    "value": {
      "type": "string",
      "description": "A value that can be referenced via an expression in the manifest"
    },
    "annotatedStringFilter": {
      "type": "string",
      "description": "Identifies the filter to apply to the referenced parameter value (for example, 'uri').",
      "enum": ["uri"]
    },
    "args": {
      "type": "array",
      "description": "List of arguments to used when launched.",
      "items": {
        "type": "string"
      }
    },
    "build": {
      "type": "object",
      "description": "An object that captures properties that control the building of a container image.",
      "required": ["context", "dockerfile"],
      "properties": {
        "context": {
          "type": "string",
          "description": "The path to the context directory for the container build. Can be relative of absolute. If relative it is relative to the location of the manifest file."
        },
        "dockerfile": {
          "type": "string",
          "description": "The path to the Dockerfile. Can be relative or absolute. If relative it is relative to the manifest file."
        },
        "args": {
          "type": "object",
          "description": "A list of build arguments which are used during container build.",
          "additionalProperties": {
            "type": "string"
          }
        },
        "secrets": {
          "type": "object",
          "description": "A list of build arguments which are used during container build.",
          "additionalProperties": {
            "type": "object",
            "required": ["type"],
            "oneOf": [
              {
                "required": ["type", "value"],
                "properties": {
                  "type": {
                    "type": "string",
                    "const": "env"
                  },
                  "value": {
                    "type": "string",
                    "description": "If provided use as the value for the environment variable when docker build is run."
                  }
                }
              },
              {
                "required": ["type", "source"],
                "properties": {
                  "type": {
                    "type": "string",
                    "const": "file"
                  },
                  "source": {
                    "type": "string",
                    "description": "Path to secret file. If relative, the path is relative to the manifest file."
                  }
                }
              }
            ]
          }
        }
      },
      "additionalProperties": false
    },
    "buildArgs": {
      "type": "object",
      "description": "A list of build arguments which are used during container build (for dockerfile.v0 resource type).",
      "additionalProperties": {
        "type": "string"
      }
    },
    "bindings": {
      "type": "object",
      "description": "A list of port bindings for the resource when it is deployed.",
      "additionalProperties": {
        "type": "object",
        "required": ["scheme", "protocol", "transport"],
        "properties": {
          "scheme": {
            "type": "string",
            "description": "The scheme used in URIs for this binding.",
            "enum": ["http", "https", "tcp", "udp"]
          },
          "protocol": {
            "type": "string",
            "description": "The protocol used for this binding (only 'tcp' or 'udp' are valid).",
            "enum": ["tcp", "udp"]
          },
          "transport": {
            "type": "string",
            "description": "Additional information describing the transport (e.g. HTTP/2).",
            "enum": ["http", "http2", "tcp"]
          },
          "external": {
            "type": "boolean",
            "description": "A flag indicating whether this binding is exposed externally when deployed."
          },
          "targetPort": {
            "type": "number",
            "description": "The port that the workload (e.g. container) is listening on."
          },
          "port": {
            "type": "number",
            "description": "The port that the workload (e.g. container) is exposed as to other resources and externally."
          }
        },
        "additionalProperties": false
      }
    },
    "env": {
      "type": "object",
      "description": "A list of environment variables which are inserted into the resource at runtime.",
      "additionalProperties": {
        "type": "string"
      }
    },
    "volumes": {
      "type": "array",
      "description": "A list of volumes associated with this resource when deployed.",
      "items": {
        "type": "object",
        "required": ["name", "target", "readOnly"],
        "properties": {
          "name": {
            "type": "string",
            "description": "The name of the volume."
          },
          "target": {
            "type": "string",
            "description": "The target within the container where the volume is mounted."
          },
          "readOnly": {
            "type": "boolean",
            "description": "Flag indicating whether the mount is read-only."
          }
        },
        "additionalProperties": false
      }
    },
    "bindMounts": {
      "type": "array",
      "description": "A list of bind mounts associated with this resource when deployed.",
      "items": {
        "type": "object",
        "required": ["source", "target", "readOnly"],
        "properties": {
          "source": {
            "type": "string",
            "description": "The source path on the host which is mounted into the container."
          },
          "target": {
            "type": "string",
            "description": "The target within the container where the volume is mounted."
          },
          "readOnly": {
            "type": "boolean",
            "description": "Flag indicating whether the mount is read-only."
          }
        },
        "additionalProperties": false
      }
    }
  }
}
