{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://schemas.optics-design.com/odfoss/v0.1.0/osj.schema.json",
  "title": "ODFOSS input envelope",
  "description": "Canonical envelope with odfoss-specific inputs.* shape",
  "type": "object",
  "required": ["inputs"],
  "properties": {
    "inputs": {
      "type": "object",
      "required": ["system"],
      "properties": {
        "metadata": {
          "type": "object",
          "description": "Optional descriptive information",
          "properties": {
            "title":  {"type": "string"},
            "author": {"type": "string"},
            "notes":  {"type": "string"}
          }
        },
        "system": {
          "type": "object",
          "required": ["surfaces"],
          "properties": {
            "surfaces": {
              "type": "array",
              "items": {
                "type": "object",
                "required": ["type"],
                "properties": {
                  "type": {"type": "string", "enum": ["object", "parax_lens", "image"]},
                  "f":    {"type": "number"},
                  "t":    {"oneOf": [{"type": "number"}, {"type": "string", "enum": ["infinity"]}, {"type": "null"}]},
                  "stop": {"type": "boolean"},
                  "solve": {
                    "type": "object",
                    "required": ["param"],
                    "properties": {
                      "param":  {"type": "string", "enum": ["f", "t"]},
                      "target": {"type": "string"},
                      "value":  {"oneOf": [{"type": "number"}, {"type": "string", "enum": ["infinity"]}]}
                    }
                  }
                }
              }
            },
            "properties": {
              "type": "object",
              "properties": {
                "aperture": {
                  "type": "object",
                  "properties": {
                    "type":  {"type": "string", "enum": ["EPD", "FNO", "NA"]},
                    "value": {"type": "number"}
                  }
                },
                "first_order": {
                  "type": "object",
                  "description": "User-provided expected values for mismatch warnings"
                }
              }
            }
          }
        },
        "compute": {
          "type": "object",
          "properties": {
            "output": {"type": "array", "items": {"type": "string"}},
            "solve": {"type": "object"}
          }
        }
      }
    }
  }
}
