|
| 1 | +using System.Reflection; |
1 | 2 | using System.Text.Json.Serialization; |
2 | 3 | using EntityFrameworkCore.DataEncryption.Sample.Context; |
3 | 4 | using Microsoft.EntityFrameworkCore; |
|
14 | 15 | options.UseNpgsql(builder.Configuration.GetConnectionString("DefaultConnection")); |
15 | 16 | }); |
16 | 17 |
|
| 18 | +// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle |
| 19 | +builder.Services.AddEndpointsApiExplorer(); |
| 20 | +builder.Services.AddSwaggerGen(options => |
| 21 | +{ |
| 22 | + options.SwaggerDoc("DataEncryption", new Microsoft.OpenApi.Models.OpenApiInfo() |
| 23 | + { |
| 24 | + Title = "EntityFrameworkCore.DataEncryption", |
| 25 | + Version = "1.0.0", |
| 26 | + Description = "This package is a plugin that adds Data Encryption support to EntityFrameworkCore.", |
| 27 | + Contact = new Microsoft.OpenApi.Models.OpenApiContact() |
| 28 | + { |
| 29 | + Email = "furkan.dvlp@gmail.com", |
| 30 | + Url = new Uri("https://github.com/furkandeveloper/EntityFrameworkCore.DataEncryption") |
| 31 | + } |
| 32 | + }); |
| 33 | + var docFile = $"{Assembly.GetEntryAssembly()?.GetName().Name}.xml"; |
| 34 | + var filePath = Path.Combine(AppContext.BaseDirectory, docFile); |
| 35 | + |
| 36 | + if (File.Exists((filePath))) |
| 37 | + { |
| 38 | + options.IncludeXmlComments(filePath); |
| 39 | + } |
| 40 | + options.DescribeAllParametersInCamelCase(); |
| 41 | +}); |
| 42 | + |
17 | 43 | var app = builder.Build(); |
18 | 44 |
|
19 | 45 | if (app.Environment.IsDevelopment()) |
20 | 46 | { |
21 | 47 | app.UseDeveloperExceptionPage(); |
22 | 48 | } |
23 | 49 |
|
| 50 | +app.UseRouting(); |
| 51 | + |
| 52 | +app.UseSwagger(); |
| 53 | + |
| 54 | +app.UseSwaggerUI(options => |
| 55 | +{ |
| 56 | + options.EnableDeepLinking(); |
| 57 | + options.ShowExtensions(); |
| 58 | + options.DisplayRequestDuration(); |
| 59 | + options.DocExpansion(Swashbuckle.AspNetCore.SwaggerUI.DocExpansion.None); |
| 60 | + options.RoutePrefix = "api-docs"; |
| 61 | + options.SwaggerEndpoint("/swagger/DataEncryption/swagger.json", "EasyProfilerSwagger"); |
| 62 | +}); |
24 | 63 | app.MapControllers(); |
25 | 64 |
|
26 | 65 | app.MapDefaultControllerRoute(); |
|
0 commit comments