Skip to content

Commit

Permalink
update openapi tags
Browse files Browse the repository at this point in the history
  • Loading branch information
silvioheinze committed Oct 10, 2024
1 parent d1a770b commit bf62995
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
13 changes: 12 additions & 1 deletion code/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,18 @@
from fastapi.middleware.cors import CORSMiddleware
from routers import city_router, station_router

app = FastAPI()
app = FastAPI(
openapi_tags=[
{
"name": "station",
"description": "Operations related to station data (e.g., historical, current)."
},
{
"name": "city",
"description": "Operations related to city-level data."
}
]
)

origins = ["*"]

Expand Down
4 changes: 2 additions & 2 deletions code/routers/city.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
router = APIRouter()


@router.get("/all", tags= {"city"})
@router.get("/all", tags=["city"])
async def get_all_cities(db: Session = Depends(get_db)):
# Abfrage aller Städte in der Datenbank
cities = db.query(City, Country).join(Country, City.country_id == Country.id).all()
Expand All @@ -37,7 +37,7 @@ async def get_all_cities(db: Session = Depends(get_db)):
return response


@router.get("/current", tags= {"city", "current"})
@router.get("/current", tags=["city", "current"])
async def get_average_measurements_by_city(
city_slug: str = Query(..., description="The name of the city to get the average measurements for."),
db: Session = Depends(get_db)
Expand Down
6 changes: 3 additions & 3 deletions code/routers/station.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async def get_history_station_data(


# New endpoints
@router.get("/current", response_class=Response, tags= {"station", "current"})
@router.get("/current", response_class=Response, tags=["station", "current"])
async def get_current_station_data(
station_ids: str = None,
last_active: int = 3600,
Expand Down Expand Up @@ -120,7 +120,7 @@ async def get_current_station_data(
return Response(content=content, media_type=media_type)


@router.post("/data", tags= {"station"})
@router.post("/data", tags=["station"])
async def create_station_data(
station: StationDataCreate,
sensors: SensorsCreate,
Expand Down Expand Up @@ -227,7 +227,7 @@ async def create_station_data(
return {"status": "success"}


@router.get("/historical", response_class=Response, tags= {"station"})
@router.get("/historical", response_class=Response, tags=["station"])
async def get_historical_station_data(
station_ids: str = Query(..., description="Comma-separated list of station devices"),
start: str = Query(..., description="Supply in format: YYYY-MM-DDThh:mm. Time is optional."),
Expand Down

0 comments on commit bf62995

Please sign in to comment.