Skip to content

Fix api.weather.gov/points response handling in WeatherTools #134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Apr 8, 2025
Merged
22 changes: 15 additions & 7 deletions samples/QuickstartWeatherServer/Tools/WeatherTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,19 @@ public static async Task<string> GetForecast(
var jsonElement = jsonDocument.RootElement;
var periods = jsonElement.GetProperty("properties").GetProperty("periods").EnumerateArray();

return string.Join("\n---\n", periods.Select(period => $"""
{period.GetProperty("name").GetString()}
Temperature: {period.GetProperty("temperature").GetInt32()}°F
Wind: {period.GetProperty("windSpeed").GetString()} {period.GetProperty("windDirection").GetString()}
Forecast: {period.GetProperty("detailedForecast").GetString()}
"""));
return string.Join("\n---\n",
periods.Select(period =>
{
return $"""
Name: {period.GetProperty("name").GetString()}
Start Time: {period.GetProperty("startTime").GetString()}
End Time: {period.GetProperty("endTime").GetString()}
Temperature: {period.GetProperty("temperature").GetInt32()}°F
Wind Speed: {period.GetProperty("windSpeed").GetString()}
Wind Direction: {period.GetProperty("windDirection").GetString()}
Short Forecast: {period.GetProperty("shortForecast").GetString()}
Detailed Forecast: {period.GetProperty("detailedForecast").GetString()}
""";
}));
}
}
}