123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- using Microsoft.OpenApi.Models;
- using API.BaseModel;
- using Microsoft.AspNetCore.Mvc.Controllers;
- namespace API
- {
- public class Program
- {
- public static void Main(string[] args)
- {
- var builder = WebApplication.CreateBuilder(args);
- builder.Services.AddCors();
- builder.Services.AddControllers();
- builder.Services.AddSwaggerGen(option =>
- {
- option.SwaggerDoc("v1", new OpenApiInfo { Title = "API äëÿ ïîäáîðà àâòî", Version = "v1" });
- option.TagActionsBy(api =>
- {
- if (api.GroupName != null)
- {
- return new[] { api.GroupName };
- }
- var controllerActionDescriptor = api.ActionDescriptor as ControllerActionDescriptor;
- if (controllerActionDescriptor != null)
- {
- return new[] { controllerActionDescriptor.ControllerName };
- }
- throw new InvalidOperationException("Unable to determine tag for endpoint.");
- });
- option.DocInclusionPredicate((name, api) => true);
- });
- var app = builder.Build();
- app.MapControllerRoute(
- name: "default",
- pattern: "{controller =SongController}/{action=GetSongs}");
- app.UseCors(builder => builder.AllowAnyOrigin());
- app.UseSwagger();
- app.UseSwaggerUI(options =>
- {
- options.SwaggerEndpoint("./v1/swagger.json", "v1");
- });
- app.Run();
- }
- }
- }
|