Skip to content

Commit

Permalink
Add lang_code optional param to weather endpoint (#18)
Browse files Browse the repository at this point in the history
# Description
Add `lang_code` option to weather endpoint
Replaces `lang_code` with `lang` for api consistency and OWM compat.

# Issues
Closes #15

# Other Notes
<!-- Note any breaking changes, WIP changes, requests for input, etc.
here -->

---------

Co-authored-by: Daniel McKnight <daniel@neon.ai>
  • Loading branch information
NeonDaniel and NeonDaniel authored Apr 10, 2024
1 parent af42e88 commit 30bb9e1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion neon_hana/app/routers/api_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
5 changes: 3 additions & 2 deletions neon_hana/schema/api_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,20 @@ class WeatherAPIRequest(BaseModel):
lat: float
lon: float
unit: str = "metric"

lang_code: str = "en"
model_config = {
"json_schema_extra": {
"examples": [{
"api": "onecall",
"lat": 47.6815,
"lon": -122.2087,
"unit": "imperial",
"lang_code": "en"
}, {
"api": "onecall",
"lat": 47.6815,
"lon": -122.2087,
"unit": "metric",
"unit": "metric"
}]}}


Expand Down

0 comments on commit 30bb9e1

Please sign in to comment.