178 lines
5.2 KiB
JSON
178 lines
5.2 KiB
JSON
{
|
|
"openapi": "3.1.0",
|
|
"info": {
|
|
"title": "Weather API",
|
|
"version": "1.0.0",
|
|
"description": "API for submitting and retrieving weather reports"
|
|
},
|
|
"servers": [
|
|
{
|
|
"url": "http://localhost:3000/v1"
|
|
}
|
|
],
|
|
"components": {
|
|
"schemas": {
|
|
"WeatherReport": {
|
|
"type": "object",
|
|
"properties": {
|
|
"latitude": {
|
|
"type": "number",
|
|
"description": "Latitude coordinate of the weather station"
|
|
},
|
|
"longitude": {
|
|
"type": "number",
|
|
"description": "Longitude coordinate of the weather station"
|
|
},
|
|
"temperature": {
|
|
"type": "number",
|
|
"description": "Temperature in degrees Celsius"
|
|
},
|
|
"pressure": {
|
|
"type": "number",
|
|
"description": "Atmospheric pressure in hPa"
|
|
},
|
|
"humidity": {
|
|
"type": "number",
|
|
"description": "Relative humidity in percentage"
|
|
},
|
|
"date_time": {
|
|
"type": "string",
|
|
"format": "date-time",
|
|
"description": "Date and time of the weather report in ISO 8601 format. If not provided, the current date/time is assumed."
|
|
},
|
|
"wind_speed": {
|
|
"type": "number",
|
|
"description": "Wind speed in meters per second (optional)"
|
|
},
|
|
"wind_direction": {
|
|
"type": "string",
|
|
"description": "Wind direction (optional)"
|
|
},
|
|
"rainfall": {
|
|
"type": "number",
|
|
"description": "Rainfall amount in millimeters (optional)"
|
|
},
|
|
"conditions": {
|
|
"type": "string",
|
|
"description": "Text description of current weather conditions (optional)"
|
|
}
|
|
},
|
|
"required": ["latitude", "longitude", "temperature", "pressure", "humidity"]
|
|
}
|
|
}
|
|
},
|
|
"paths": {
|
|
"/v1/reports/{station_id}": {
|
|
"post": {
|
|
"summary": "Submit a weather report",
|
|
"description": "Endpoint for users to submit weather reports.",
|
|
"parameters": [
|
|
{
|
|
"name": "station_id",
|
|
"in": "path",
|
|
"required": true,
|
|
"schema": {
|
|
"type": "string",
|
|
"description": "The ID of the weather station"
|
|
},
|
|
"description": "ID of the weather station"
|
|
}
|
|
],
|
|
"requestBody": {
|
|
"required": true,
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/WeatherReport"
|
|
}
|
|
}
|
|
},
|
|
"responses": {
|
|
"201": {
|
|
"description": "Weather report submitted successfully"
|
|
},
|
|
"400": {
|
|
"description": "Bad request, check request parameters"
|
|
},
|
|
"500": {
|
|
"description": "Internal server error"
|
|
}
|
|
},
|
|
"security": []
|
|
}
|
|
}
|
|
},
|
|
"/v1/reports/{station_id}/history": {
|
|
"get": {
|
|
"summary": "Get weather reports in reverse chronological order",
|
|
"description": "Endpoint to retrieve weather reports for a station in reverse chronological order.",
|
|
"parameters": [
|
|
{
|
|
"name": "station_id",
|
|
"in": "path",
|
|
"required": true,
|
|
"schema": {
|
|
"type": "string",
|
|
"description": "The ID of the weather station"
|
|
},
|
|
"description": "ID of the weather station"
|
|
},
|
|
{
|
|
"name": "start",
|
|
"in": "query",
|
|
"required": false,
|
|
"schema": {
|
|
"type": "string",
|
|
"format": "date-time",
|
|
"description": "Starting date/time to retrieve reports from in ISO 8601 format"
|
|
},
|
|
"description": "Starting date/time to retrieve reports from (optional)"
|
|
},
|
|
{
|
|
"name": "end",
|
|
"in": "query",
|
|
"required": false,
|
|
"schema": {
|
|
"type": "string",
|
|
"description": "Latest date/time to retrieve reports from in ISO 8601 format"
|
|
},
|
|
"description": "Latest date/time to retrieve reports from (optional)"
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "Successful response",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"type": "object",
|
|
"properties": {
|
|
"reports": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/components/schemas/WeatherReport"
|
|
}
|
|
},
|
|
"next": {
|
|
"type": "string",
|
|
"description": "URL to request for more data (pagination)"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"400": {
|
|
"description": "Bad request, check request parameters"
|
|
},
|
|
"500": {
|
|
"description": "Internal server error"
|
|
}
|
|
},
|
|
"security": []
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|