ABPCMS.WebApi/App_Start/SwaggerConfig.cs
(开头部分) 17KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System.Web.Http;
using Jimmey.CMSProject;
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Web;
using Swashbuckle.Application;
[assembly: PreApplicationStartMethod(typeof(SwaggerConfig), "Register")]
namespace Jimmey.CMSProject
{
public class SwaggerConfig
{
public static void Register()
{
var thisAssembly = typeof(SwaggerConfig).Assembly;
GlobalConfiguration.Configuration
.EnableSwagger(c =>
{
c.SingleApiVersion("v1", "API文档");
c.ResolveConflictingActions(apiDescriptions => apiDescriptions.First());
//将application层中的注释添加到SwaggerUI中
var baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
var commentsFileName = "bin//ABPCMS.Application.xml";
var commentsFile = Path.Combine(baseDirectory, commentsFileName);
//将注释的XML文档添加到SwaggerUI中
c.IncludeXmlComments(commentsFile);
// c.SingleApiVersion("v1", "Jimmey.CMSProject");
// By default, the service root url is inferred from the request used to access the docs.
// However, there may be situations (e.g. proxy and load-balanced environments) where this does not
// resolve correctly. You can workaround this by providing your own code to determine the root URL.
//
//c.RootUrl(req => GetRootUrlFromAppConfig());
// If schemes are not explicitly provided in a Swagger 2.0 document, then the scheme used to access
// the docs is taken as the default. If your API supports multiple schemes and you want to be explicit
// about them, you can use the "Schemes" option as shown below.
//
//c.Schemes(new[] { "http", "https" });
// Use "SingleApiVersion" to describe a single version API. Swagger 2.0 includes an "Info" object to
// hold additional metadata for an API. Version and title are required but you can also provide
// additional fields by chaining methods off SingleApiVersion.
//
// If you want the output Swagger docs to be indented properly, enable the "PrettyPrint" option.
//
//c.PrettyPrint();
后面还有 215 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
