Няма описание

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using Microsoft.AspNetCore.Builder;
  2. using Microsoft.Extensions.DependencyInjection;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.IO;
  6. using System.Linq;
  7. using System.Reflection;
  8. using System.Threading.Tasks;
  9. namespace Backend.API.Config
  10. {
  11. internal static class SwaggerExtensions
  12. {
  13. internal static IServiceCollection AddSwaggerDocumentation(this IServiceCollection services)
  14. {
  15. services.AddSwaggerGen(options =>
  16. {
  17. options.SwaggerDoc("v1", new Microsoft.OpenApi.Models.OpenApiInfo
  18. {
  19. Title = "Sample CQRS Catalogue.Backend.API",
  20. Version = "v1",
  21. Description = "Sample .NET Core REST API CQRS implementation using Clean Architecture.",
  22. });
  23. var baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
  24. var commentsFileName = Assembly.GetExecutingAssembly().GetName().Name + ".XML";
  25. var commentsFile = Path.Combine(baseDirectory, commentsFileName);
  26. // options.IncludeXmlComments(commentsFile);
  27. });
  28. return services;
  29. }
  30. internal static IApplicationBuilder UseSwaggerDocumentation(this IApplicationBuilder app)
  31. {
  32. app.UseSwagger();
  33. app.UseSwaggerUI(c =>
  34. {
  35. c.SwaggerEndpoint("/swagger/v1/swagger.json", "Sample CQRS API V1");
  36. });
  37. return app;
  38. }
  39. }
  40. }

Powered by TurnKey Linux.