| | |
| | | using System.Web.Http; |
| | | using WebActivatorEx; |
| | | using IStation.WebApi; |
| | | using Swashbuckle.Application; |
| | | using System; |
| | | using System.Web; |
| | | |
| | | [assembly: PreApplicationStartMethod(typeof(SPump.TransferApi.SwaggerConfig), "Register")] |
| | | [assembly: PreApplicationStartMethod(typeof(SwaggerConfig), "Register")] |
| | | |
| | | namespace SPump.TransferApi |
| | | namespace IStation.WebApi |
| | | { |
| | | /// <summary> |
| | | /// SwaggerConfig |
| | | /// </summary> |
| | | public class SwaggerConfig |
| | | { |
| | | /// <summary> |
| | | /// 注册 |
| | | /// </summary> |
| | | public static void Register() |
| | | { |
| | | var isUseSwagger = System.Configuration.ConfigurationManager.AppSettings["IsUseSwagger"]; |
| | | if(!string.IsNullOrEmpty(isUseSwagger) && !Convert.ToBoolean(isUseSwagger)) |
| | | { |
| | | return; |
| | | } |
| | | var thisAssembly = typeof(SwaggerConfig).Assembly; |
| | | |
| | | GlobalConfiguration.Configuration |
| | |
| | | // hold additional metadata for an API. Version and title are required but you can also provide |
| | | // additional fields by chaining methods off SingleApiVersion. |
| | | // |
| | | c.SingleApiVersion("v1", "义维SPump api接口平台"); |
| | | c.SingleApiVersion("v1", "IStation.WebApi"); |
| | | |
| | | // If you want the output Swagger docs to be indented properly, enable the "PrettyPrint" option. |
| | | // |
| | |
| | | // those comments into the generated docs and UI. You can enable this by providing the path to one or |
| | | // more Xml comment files. |
| | | // |
| | | c.IncludeXmlComments(GetXmlCommentsPath()); |
| | | //c.IncludeXmlComments(GetXmlCommentsPath()); |
| | | |
| | | // Swashbuckle makes a best attempt at generating Swagger compliant JSON schemas for the various types |
| | | // exposed in your API. However, there may be occasions when more control of the output is needed. |
| | |
| | | // Use the "DocumentTitle" option to change the Document title. |
| | | // Very helpful when you have multiple Swagger pages open, to tell them apart. |
| | | // |
| | | c.DocumentTitle("Spump api ƽ̨"); |
| | | //c.DocumentTitle("My Swagger UI"); |
| | | |
| | | // Use the "InjectStylesheet" option to enrich the UI with one or more additional CSS stylesheets. |
| | | // The file must be included in your project as an "Embedded Resource", and then the resource's |
| | |
| | | // |
| | | //c.EnableApiKeySupport("apiKey", "header"); |
| | | }); |
| | | } |
| | | |
| | | private static string GetXmlCommentsPath() |
| | | { |
| | | return String.Format(@"{0}bin\SPump.TransferApi.xml", System.AppDomain.CurrentDomain.BaseDirectory); |
| | | } |
| | | } |
| | | } |