using System.Reflection; using Microsoft.OpenApi.Models; var builder = WebApplication.CreateBuilder(args); builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(options => { options.SwaggerDoc("v1", new OpenApiInfo { Title = "FPGA Web Lab API", Description = "Use FPGA in the cloud", Version = "v1" }); // Generate Doc and Exam var executingAssembly = Assembly.GetExecutingAssembly(); var xmlFilename = $"{executingAssembly.GetName().Name}.xml"; options.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, xmlFilename)); var referencedProjectsXmlDocPaths = executingAssembly.GetReferencedAssemblies() .Where(assembly => assembly.Name != null && assembly.Name.StartsWith("server", StringComparison.InvariantCultureIgnoreCase)) .Select(assembly => Path.Combine(AppContext.BaseDirectory, $"{assembly.Name}.xml")) .Where(path => File.Exists(path)); foreach (var xmlDocPath in referencedProjectsXmlDocPaths) options.IncludeXmlComments(xmlDocPath); }); var app = builder.Build(); if (app.Environment.IsDevelopment()) { app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "FPAG WebLab API V1"); }); } // Setup Program MsgBus.Init(); // Router app.MapGet("/", () => "Hello World!"); app.MapPut("/api/SendString", Router.API.SendString); app.MapPut("/api/SendAddrPackage", Router.API.SendAddrPackage); app.MapPut("/api/SendDataPackage", Router.API.SendDataPackage); app.MapPut("/api/jtag/RunCommand", Router.API.Jtag.RunCommand); app.MapPut("/api/jtag/GetIDCode", Router.API.Jtag.GetDeviceIDCode); app.Run("http://localhost:5000"); // Close UDP Server Console.WriteLine("Program is Closing now..."); MsgBus.Exit();