From 1af49bdb3cdaa44a7e44ebdc843fb8180596365f Mon Sep 17 00:00:00 2001 From: kazelee <1847801760@qq.com> Date: 星期四, 15 五月 2025 16:34:39 +0800 Subject: [PATCH] 尾箱回库、移库逻辑开发 --- App_Start/SwaggerConfig.cs | 47 +++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 43 insertions(+), 4 deletions(-) diff --git a/AppStart/SwaggerConfig.cs b/App_Start/SwaggerConfig.cs similarity index 90% rename from AppStart/SwaggerConfig.cs rename to App_Start/SwaggerConfig.cs index 557097d..7d069fe 100644 --- a/AppStart/SwaggerConfig.cs +++ b/App_Start/SwaggerConfig.cs @@ -1,14 +1,49 @@ using System.Web.Http; using WebActivatorEx; -using HH.WCS.Mobox3.Template; +using HH.WCS.Mobox3.DSZSH; using Swashbuckle.Application; +using System.IO; +using System.Reflection; +using System; +using Swashbuckle.Examples; [assembly: PreApplicationStartMethod(typeof(SwaggerConfig), "Register")] -namespace HH.WCS.Mobox3.Template +namespace HH.WCS.Mobox3.DSZSH { public class SwaggerConfig { + public static void Register(HttpConfiguration config) { + var thisAssembly = typeof(SwaggerConfig).Assembly; + + config + .EnableSwagger(c => { + c.SingleApiVersion("v1", "HH.WCS.Mobox3.DSZSH"); + + // 璁剧疆 XML 娉ㄩ噴璺緞 + var baseDirectory = AppDomain.CurrentDomain.BaseDirectory; + //var commentsFileName = Assembly.GetExecutingAssembly().GetName().Name + ".xml"; + var commentsFileName = "bin\\Debug\\HH.WCS.Mobox3.DSZSH.xml"; + var commentsFile = Path.Combine(baseDirectory, commentsFileName); + + if (File.Exists(commentsFile)) { + c.IncludeXmlComments(commentsFile); + } + + // 鍏朵粬閰嶇疆... + c.UseFullTypeNameInSchemaIds(); + + // 鍚敤绀轰緥鏁版嵁 + //c.DescribeAllEnumsAsStrings(); + //c.OperationFilter<ExamplesOperationFilter>(); + //c.ModelFilter<ExamplesModelFilter>(); + + }) + .EnableSwaggerUi(c => { + // UI 閰嶇疆 + }); + } + public static void Register() { var thisAssembly = typeof(SwaggerConfig).Assembly; @@ -32,7 +67,7 @@ // 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", "HH.WCS.Mobox3.Template"); + c.SingleApiVersion("v1", "HH.WCS.Mobox3.DSZSH"); // If you want the output Swagger docs to be indented properly, enable the "PrettyPrint" option. // @@ -61,7 +96,7 @@ //c.BasicAuth("basic") // .Description("Basic HTTP Authentication"); // - // NOTE: You must also configure 'EnableApiKeySupport' below in the SwaggerUI section + // NOTE: You must also configure 'EnableApiKeySupport' below in the SwaggerUI section //c.ApiKey("apiKey") // .Description("API Key Authentication") // .Name("apiKey") @@ -103,6 +138,10 @@ // //c.IncludeXmlComments(GetXmlCommentsPath()); + // 鍚敤 XML 娉ㄩ噴 + var xmlFile = $"{System.AppDomain.CurrentDomain.BaseDirectory}\\HH.WCS.Mobox3.DSZSH.xml"; + c.IncludeXmlComments(xmlFile); + // 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. // This is supported through the "MapType" and "SchemaFilter" options: -- Gitblit v1.9.1