/ Existing Blazor project: Program.cs (Startup class) public void ConfigureServices(IServiceCollection services) { // ... other service registrations services.AddEndpointsApiExplorer(); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "My Blazor API", Version = "v1" }); }); } public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { // ... other configuration app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "My Blazor API v1"); }); app.MapGet("/api/weather", async (httpContext) => { // Fetch weather data from your service var forecasts = await _weatherService.GetForecasts(); await httpContext.Response.WriteAsJsonAsync(forecasts); });