this repo has no description
1var builder = WebApplication.CreateBuilder(args);
2
3// Add services to the container.
4// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
5builder.Services.AddOpenApi();
6
7var app = builder.Build();
8
9// Configure the HTTP request pipeline.
10if (app.Environment.IsDevelopment())
11{
12 app.MapOpenApi();
13}
14
15app.UseHttpsRedirection();
16
17var summaries = new[]
18{
19 "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
20};
21
22app.MapGet("/weatherforecast", () =>
23{
24 var forecast = Enumerable.Range(1, 5).Select(index =>
25 new WeatherForecast
26 (
27 DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
28 Random.Shared.Next(-20, 55),
29 summaries[Random.Shared.Next(summaries.Length)]
30 ))
31 .ToArray();
32 return forecast;
33})
34.WithName("GetWeatherForecast");
35
36app.Run();
37
38record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary)
39{
40 public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
41}