Last active
December 28, 2025 13:35
-
-
Save sunmeat/fc781f9302888e1127ad5fcb12484367 to your computer and use it in GitHub Desktop.
swagger UI
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
| namespace WebApplication1 | |
| { | |
| public class Program | |
| { | |
| public static void Main(string[] args) | |
| { | |
| var builder = WebApplication.CreateBuilder(args); | |
| builder.Services.AddControllers(); | |
| builder.Services.AddOpenApi(); | |
| builder.Services.AddEndpointsApiExplorer(); // сканує ендпоінти для генерації OpenAPI-документу | |
| builder.Services.AddSwaggerGen(); // генерує OpenAPI-документ на основі відсканованих ендпоінтів | |
| var app = builder.Build(); | |
| if (app.Environment.IsDevelopment()) | |
| { | |
| app.MapOpenApi(); | |
| app.UseSwagger(); // генерує /swagger/v1/swagger.json | |
| app.UseSwaggerUI(); // UI на /swagger | |
| } | |
| 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": "swagger", // відкриває безпосередньо сторінку Swagger | |
| "applicationUrl": "http://localhost:5274", | |
| "environmentVariables": { | |
| "ASPNETCORE_ENVIRONMENT": "Development" | |
| } | |
| }, | |
| "https": { | |
| "commandName": "Project", | |
| "dotnetRunMessages": true, | |
| "launchBrowser": true, // змінили на true | |
| "launchUrl": "swagger", // відкриває безпосередньо сторінку Swagger | |
| "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