Advertisement
adamw00000

Untitled

Jan 21st, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.86 KB | None | 0 0
  1.             services.AddSwaggerGen(c =>
  2.             {
  3.                 //The generated Swagger JSON file will have these properties.
  4.                 c.SwaggerDoc("v1", new Info
  5.                 {
  6.                     Title = "Swagger XML Api",
  7.                     Version = "v1",
  8.                 });
  9.  
  10.                 //Locate the XML file being generated by ASP.NET...
  11.                 var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
  12.                 var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
  13.  
  14.                 //... and tell Swagger to use those XML comments.
  15.                 c.IncludeXmlComments(xmlPath);
  16.             });
  17.         }
  18.        
  19.        
  20.        
  21.             app.UseSwagger();
  22.             app.UseSwaggerUI(c =>
  23.             {
  24.                 c.SwaggerEndpoint("/swagger/v1/swagger.json", "Swagger XML Api v1");
  25.             });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement