{
  "openapi": "3.1.0",
  "info": {
    "title": "DevRev Challenge Traffic Light API",
    "version": "1.0.0",
    "description": "Demo API for operating a traffic light through authenticated API calls."
  },
  "servers": [
    {
      "url": "http://63.35.230.199.sslip.io"
    }
  ],
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key"
      },
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "LightStatus": {
        "type": "object",
        "properties": {
          "color": {
            "type": "string",
            "enum": [
              "red",
              "amber",
              "green"
            ]
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "SetLightRequest": {
        "type": "object",
        "required": [
          "color"
        ],
        "properties": {
          "color": {
            "type": "string",
            "enum": [
              "red",
              "amber",
              "green"
            ]
          }
        }
      }
    }
  },
  "security": [
    {
      "ApiKeyAuth": []
    },
    {
      "BearerAuth": []
    }
  ],
  "paths": {
    "/api/colors": {
      "get": {
        "summary": "List available colors",
        "responses": {
          "200": {
            "description": "Supported traffic light colors"
          },
          "401": {
            "description": "Missing or invalid API key"
          }
        }
      }
    },
    "/api/status": {
      "get": {
        "summary": "Get current status",
        "responses": {
          "200": {
            "description": "Current traffic light state"
          },
          "401": {
            "description": "Missing or invalid API key"
          }
        }
      }
    },
    "/api/light": {
      "put": {
        "summary": "Set light color",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SetLightRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated traffic light state"
          },
          "400": {
            "description": "Invalid color"
          },
          "401": {
            "description": "Missing or invalid API key"
          }
        }
      },
      "post": {
        "summary": "Set light color",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SetLightRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated traffic light state"
          },
          "400": {
            "description": "Invalid color"
          },
          "401": {
            "description": "Missing or invalid API key"
          }
        }
      }
    }
  }
}