|
18 | 18 | using StrDss.Service.Bceid;
|
19 | 19 | using Npgsql;
|
20 | 20 | using Serilog;
|
21 |
| -using Microsoft.AspNetCore.Authentication; |
| 21 | +using Microsoft.Extensions.Options; |
| 22 | +using Swashbuckle.AspNetCore.SwaggerGen; |
| 23 | +using StrDss.Common; |
22 | 24 |
|
23 | 25 | var builder = WebApplication.CreateBuilder(args);
|
24 | 26 |
|
|
158 | 160 |
|
159 | 161 | // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
160 | 162 | builder.Services.AddEndpointsApiExplorer();
|
161 |
| -builder.Services.AddSwaggerGen(); |
| 163 | +builder.Services.AddTransient<IConfigureOptions<SwaggerGenOptions>, ConfigureSwaggerOptions>(); |
| 164 | +builder.Services.AddSwaggerGen(options => |
| 165 | +{ |
| 166 | + options.EnableAnnotations(); |
| 167 | + options.UseAllOfToExtendReferenceSchemas(); |
| 168 | + var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; |
| 169 | + var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); |
| 170 | + options.IncludeXmlComments(xmlPath); |
| 171 | +}); |
162 | 172 |
|
163 | 173 | var healthCheck = new HealthCheck(connString);
|
164 | 174 | builder.Services.AddHealthChecks().AddCheck("DbConnection", healthCheck);
|
|
168 | 178 | // Configure the HTTP request pipeline.
|
169 | 179 | if (app.Environment.IsDevelopment())
|
170 | 180 | {
|
171 |
| - app.UseSwagger(); |
172 |
| - app.UseSwaggerUI(); |
| 181 | + app.UseSwagger(option => |
| 182 | + { |
| 183 | + option.RouteTemplate = "api/swagger/{documentName}/swagger.json"; |
| 184 | + }); |
| 185 | + |
| 186 | + app.UseSwaggerUI(option => |
| 187 | + { |
| 188 | + option.SwaggerEndpoint($"/api/swagger/{ApiTags.Default}/swagger.json", ApiTags.Default); |
| 189 | + option.SwaggerEndpoint($"/api/swagger/{ApiTags.Aps}/swagger.json", ApiTags.Aps); |
| 190 | + |
| 191 | + option.RoutePrefix = "api/swagger"; |
| 192 | + }); |
173 | 193 | }
|
174 | 194 |
|
175 | 195 | app.UseHealthChecks("/healthz");
|
|
0 commit comments