{
  "openapi": "3.0.3",
  "info": {
    "title": "Weather API",
    "description": "A RESTful interface providing weather information including current conditions, forecasts, and climate data.",
    "version": "1.0.0",
    "termsOfService": "https://example.com/terms",
    "contact": {
      "name": "API Support",
      "url": "https://example.com/support",
      "email": "support@example.com"
    },
    "license": {
      "name": "Apache 2.0",
      "url": "https://www.apache.org/licenses/LICENSE-2.0.html"
    }
  },
  "servers": [
    {
      "url": "https://api.example.com/v1",
      "description": "Production server"
    },
    {
      "url": "https://staging-api.example.com/v1",
      "description": "Staging server"
    }
  ],
  "paths": {
    "/weather/current": {
      "get": {
        "summary": "Get current weather conditions",
        "description": "Retrieve the current weather conditions for a specified location.",
        "parameters": [
          {
            "name": "location",
            "in": "query",
            "description": "City name or geographic coordinates (lat,lon) to retrieve weather for.",
            "required": true,
            "schema": {
              "type": "string",
              "example": "New York"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current weather retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CurrentWeather"
                }
              }
            }
          },
          "400": {
            "description": "Invalid location parameter"
          },
          "404": {
            "description": "Weather data not found"
          }
        }
      }
    },
    "/weather/forecast": {
      "get": {
        "summary": "Get weather forecast",
        "description": "Retrieve a multi-day weather forecast for a specified location.",
        "parameters": [
          {
            "name": "location",
            "in": "query",
            "description": "City name or coordinates to retrieve forecast for.",
            "required": true,
            "schema": {
              "type": "string",
              "example": "New York"
            }
          },
          {
            "name": "days",
            "in": "query",
            "description": "Number of days of forecast to retrieve",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 5,
              "minimum": 1,
              "maximum": 14
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Forecast retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Forecast"
                }
              }
            }
          },
          "400": {
            "description": "Invalid parameters"
          },
          "404": {
            "description": "Forecast data not found"
          }
        }
      }
    },
    "/weather/climateNormals": {
      "get": {
        "summary": "Get climate normals",
        "description": "Retrieve historical climate normals (e.g., average temperatures, rainfall) for a specified location.",
        "parameters": [
          {
            "name": "location",
            "in": "query",
            "description": "City name or coordinates.",
            "required": true,
            "schema": {
              "type": "string",
              "example": "New York"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Climate normals retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClimateNormals"
                }
              }
            }
          },
          "400": {
            "description": "Invalid location"
          },
          "404": {
            "description": "Data not found"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "CurrentWeather": {
        "type": "object",
        "properties": {
          "location": {
            "type": "string"
          },
          "temperature": {
            "type": "number"
          },
          "humidity": {
            "type": "number"
          },
          "description": {
            "type": "string"
          },
          "windSpeed": {
            "type": "number"
          },
          "timestamp": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "location",
          "temperature",
          "description",
          "timestamp"
        ]
      },
      "Forecast": {
        "type": "object",
        "properties": {
          "location": {
            "type": "string"
          },
          "forecasts": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "date": {
                  "type": "string",
                  "format": "date"
                },
                "minTemperature": {
                  "type": "number"
                },
                "maxTemperature": {
                  "type": "number"
                },
                "description": {
                  "type": "string"
                }
              },
              "required": [
                "date",
                "minTemperature",
                "maxTemperature",
                "description"
              ]
            }
          }
        },
        "required": [
          "location",
          "forecasts"
        ]
      },
      "ClimateNormals": {
        "type": "object",
        "properties": {
          "location": {
            "type": "string"
          },
          "averageHigh": {
            "type": "number"
          },
          "averageLow": {
            "type": "number"
          },
          "averagePrecipitation": {
            "type": "number"
          },
          "recordHigh": {
            "type": "number"
          },
          "recordLow": {
            "type": "number"
          }
        },
        "required": [
          "location",
          "averageHigh",
          "averageLow",
          "averagePrecipitation"
        ]
      }
    },
    "securitySchemes": {
      "apiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key"
      }
    }
  },
  "security": [
    {
      "apiKeyAuth": []
    }
  ]
}