{
  "openapi": "3.1.0",
  "info": {
    "title": "Time to Decimal API",
    "version": "1.0.0",
    "description": "Convert clock time to decimal hours and decimal hours to clock time. Free, no key, CORS enabled."
  },
  "servers": [{ "url": "https://www.timetodecimalcalculator.com" }],
  "paths": {
    "/api/convert": {
      "get": {
        "operationId": "convertTime",
        "summary": "Convert time to decimal hours, or decimal hours to time",
        "description": "Pass exactly one of `time` or `decimal`.",
        "parameters": [
          {
            "name": "time",
            "in": "query",
            "required": false,
            "description": "Duration as H:MM, H:MM:SS or units like '7h 45m 30s'.",
            "schema": { "type": "string", "examples": ["7:45", "1:30:36", "7h 45m"] }
          },
          {
            "name": "decimal",
            "in": "query",
            "required": false,
            "description": "Non-negative decimal hours, e.g. 7.75.",
            "schema": { "type": "number", "minimum": 0, "examples": [7.75] }
          }
        ],
        "responses": {
          "200": {
            "description": "Conversion result",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "title": "TimeToDecimal",
                      "type": "object",
                      "properties": {
                        "input": { "type": "string" },
                        "hours": { "type": "number" },
                        "minutes": { "type": "number" },
                        "seconds": { "type": "number" },
                        "decimalHours": { "type": "number", "description": "Rounded to 6 places" },
                        "decimalHoursRounded2": { "type": "number" },
                        "totalMinutes": { "type": "number" },
                        "totalSeconds": { "type": "number" },
                        "formula": { "type": "string" }
                      }
                    },
                    {
                      "title": "DecimalToTime",
                      "type": "object",
                      "properties": {
                        "input": { "type": "number" },
                        "hours": { "type": "integer" },
                        "minutes": { "type": "integer" },
                        "seconds": { "type": "integer" },
                        "hhmmss": { "type": "string" },
                        "text": { "type": "string" },
                        "totalMinutes": { "type": "number" },
                        "totalSeconds": { "type": "integer" }
                      }
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Missing or invalid input",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": { "type": "string" },
                    "usage": { "type": "array", "items": { "type": "string" } },
                    "docs": { "type": "string" }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
