В настоящее время у меня есть Directory.Build.props со следующими строками:
Код: Выделить всё
true
$(NoWarn);1570;1572;1573;1587;1591;1701;1702;1705;1591
Код: Выделить всё
// configure swagger API documentation
builder.Services.AddSwaggerGen(config => {
config.SwaggerDoc(appVersion, new OpenApiInfo {
Title = "Proj1 API",
Version = appVersion,
Description = "REST API for control of Proj1 data"
});
config.SchemaFilter();
config.OrderActionsBy(a => $"{a.RelativePath}_{a.HttpMethod}");
config.CustomSchemaIds(x => x.FullName);
// add the xml comments to the swagger generated json
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
config.IncludeXmlComments(xmlPath);
});
// build the application with all services
var app = builder.Build();
if (app.Environment.IsDevelopment()) {
// enable swagger documentation
var swaggerRoute = "api-docs";
app.UseSwagger(c => {
c.RouteTemplate = $"{swaggerRoute}/{{documentName}}/swagger.json";
});
app.UseSwaggerUI(c => {
c.SwaggerEndpoint($"/{swaggerRoute}/{appVersion}/swagger.json", $"Proj1 API {appVersion})");
c.RoutePrefix = swaggerRoute;
});
Подробнее здесь: https://stackoverflow.com/questions/758 ... swagger-ui