32 lines
696 B
C#
32 lines
696 B
C#
|
using Microsoft.OpenApi.Models;
|
||
|
|
||
|
var builder = WebApplication.CreateBuilder(args);
|
||
|
|
||
|
// Add services to the container.
|
||
|
|
||
|
builder.Services.AddControllers();
|
||
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||
|
builder.Services.AddEndpointsApiExplorer();
|
||
|
builder.Services.AddSwaggerGen();
|
||
|
|
||
|
var app = builder.Build();
|
||
|
|
||
|
app.UseSwagger(c =>
|
||
|
{
|
||
|
|
||
|
c.PreSerializeFilters.Add((swaggerDoc, httpReq) =>
|
||
|
{
|
||
|
swaggerDoc.Servers = new List<OpenApiServer> { new OpenApiServer { Url = $"{httpReq.Scheme}://{httpReq.Host.Value}/postservice" } };
|
||
|
});
|
||
|
});
|
||
|
app.UseSwaggerUI();
|
||
|
|
||
|
|
||
|
app.UseHttpsRedirection();
|
||
|
|
||
|
app.UseAuthorization();
|
||
|
|
||
|
app.MapControllers();
|
||
|
|
||
|
app.Run();
|