From 30bb9e1b1a4ab325602138790b49620bfeb076d1 Mon Sep 17 00:00:00 2001 From: Daniel McKnight <34697904+NeonDaniel@users.noreply.github.com> Date: Tue, 9 Apr 2024 17:15:27 -0700 Subject: [PATCH] Add `lang_code` optional param to weather endpoint (#18) # Description Add `lang_code` option to weather endpoint Replaces `lang_code` with `lang` for api consistency and OWM compat. # Issues Closes #15 # Other Notes --------- Co-authored-by: Daniel McKnight --- neon_hana/app/routers/api_proxy.py | 4 +++- neon_hana/schema/api_requests.py | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/neon_hana/app/routers/api_proxy.py b/neon_hana/app/routers/api_proxy.py index de37194..25135f1 100644 --- a/neon_hana/app/routers/api_proxy.py +++ b/neon_hana/app/routers/api_proxy.py @@ -36,7 +36,9 @@ @proxy_route.post("/weather") async def api_proxy_weather(query: WeatherAPIRequest) -> WeatherAPIOnecallResponse: - return mq_connector.query_api_proxy("open_weather_map", dict(query)) + query = dict(query) + query["lang"] = query.pop("lang_code") + return mq_connector.query_api_proxy("open_weather_map", query) @proxy_route.post("/stock/symbol") diff --git a/neon_hana/schema/api_requests.py b/neon_hana/schema/api_requests.py index 95ea29e..7ccd67b 100644 --- a/neon_hana/schema/api_requests.py +++ b/neon_hana/schema/api_requests.py @@ -34,7 +34,7 @@ class WeatherAPIRequest(BaseModel): lat: float lon: float unit: str = "metric" - + lang_code: str = "en" model_config = { "json_schema_extra": { "examples": [{ @@ -42,11 +42,12 @@ class WeatherAPIRequest(BaseModel): "lat": 47.6815, "lon": -122.2087, "unit": "imperial", + "lang_code": "en" }, { "api": "onecall", "lat": 47.6815, "lon": -122.2087, - "unit": "metric", + "unit": "metric" }]}}