Đối với đầy đủ sake, khi sử dụng phiên bản mới nhất của Swashbuckle.AspNetCore (2.1.0)
và Swashbuckle.SwaggerGen/Ui (6.0.0)
, cho phép Xml tạo tệp tài liệu trong dự án của bạn Xây dựng
Sau đó, theo phương thức ConfigureServices()
:
services.ConfigureSwaggerGen(options =>
{
options.SingleApiVersion(new Info
{
Version = "v1",
Title = "My API",
Description = "API Description"
});
options.DescribeAllEnumsAsStrings();
var xmlDocFile = Path.Combine(AppContext.BaseDirectory, $"{_hostingEnv.ApplicationName}.xml");
if (File.Exists(xmlDocFile))
{
var comments = new XPathDocument(xmlDocFile);
options.OperationFilter<XmlCommentsOperationFilter>(comments);
options.ModelFilter<XmlCommentsModelFilter>(comments);
}
});
Nguồn
2018-03-01 07:40:13
Tôi không nghĩ vậy. – venerik