Created
December 28, 2025 13:58
-
-
Save sunmeat/5d12dce50d4f9ab192f6677a6ee89e89 to your computer and use it in GitHub Desktop.
Scalar + ASP.NET Core Web API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using Scalar.AspNetCore; // зверніть увагу, це потрібно для налаштування Scalar | |
| namespace WebApplication1 | |
| { | |
| public class Program | |
| { | |
| public static void Main(string[] args) | |
| { | |
| var builder = WebApplication.CreateBuilder(args); | |
| builder.Services.AddControllers(); | |
| builder.Services.AddOpenApi(); | |
| var app = builder.Build(); | |
| if (app.Environment.IsDevelopment()) | |
| { | |
| app.MapOpenApi(); | |
| app.MapScalarApiReference(options => | |
| { | |
| options.Title = "Sunmeat API"; // назва вашого API, яка відображатиметься в документації | |
| options.WithTheme(ScalarTheme.Alternate); // опційно, вибір теми оформлення документації | |
| }); | |
| } | |
| app.UseHttpsRedirection(); | |
| app.UseAuthorization(); | |
| app.MapControllers(); | |
| app.Run(); | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "$schema": "https://json.schemastore.org/launchsettings.json", | |
| "profiles": { | |
| "http": { | |
| "commandName": "Project", | |
| "dotnetRunMessages": true, | |
| "launchBrowser": true, // вже було true | |
| "launchUrl": "scalar/v1", // відкриває сторінку Scalar | |
| "applicationUrl": "http://localhost:5274", | |
| "environmentVariables": { | |
| "ASPNETCORE_ENVIRONMENT": "Development" | |
| } | |
| }, | |
| "https": { | |
| "commandName": "Project", | |
| "dotnetRunMessages": true, | |
| "launchBrowser": true, // вже було true | |
| "launchUrl": "scalar/v1", // відкриває сторінку Scalar | |
| "applicationUrl": "https://localhost:7029;http://localhost:5274", | |
| "environmentVariables": { | |
| "ASPNETCORE_ENVIRONMENT": "Development" | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment