Esempio n. 1
0
 public static void UseSwaggerUI(SwaggerUIOptions c, IWebHostEnvironment env, string moduleName = "", string version = "v1")
 {
     c.SwaggerEndpoint(version + "/swagger.json", "OMSLegacy: " + moduleName + ", Env:" + env.EnvironmentName);
     c.DocExpansion(DocExpansion.None);
     c.OAuthClientId("");
     c.OAuthClientSecret("");
 }
Esempio n. 2
0
 public static void UseSwaggerUIDefault(this SwaggerUIOptions ops)
 {
     if (ops != null)
     {
         ops.RoutePrefix = "apidocs";
         ops.DocExpansion(DocExpansion.None);
     }
 }
Esempio n. 3
0
        private static void SetupSwaggerUi(SwaggerUIOptions options)
        {
            options.DocumentTitle = ProjectName;

            options.SwaggerEndpoint(SwaggerUrl, ProjectName);

            options.DocExpansion(DocExpansion.Full);
        }
Esempio n. 4
0
        public static void ConfigureUI(SwaggerUIOptions options)
        {
            options.SwaggerEndpoint($"/swagger/{SwaggerConstants.InvestorsGroup}/swagger.json", SwaggerConstants.InvestorsTitle);
            options.SwaggerEndpoint($"/swagger/{SwaggerConstants.AdministratorsGroup}/swagger.json", SwaggerConstants.AdministratorsTitle);
            options.SwaggerEndpoint($"/swagger/{SwaggerConstants.AnalyticsGroup}/swagger.json", SwaggerConstants.AnalyticsTitle);
            options.DocExpansion("list");

            options.InjectOnCompleteJavaScript("customizations/BearerAuth.js");
        }
        static void ConfigureSwaggerUI(this SwaggerUIOptions swaggerUIOptions, IApiVersionDescriptionProvider versionProvider)
        {
            foreach (var apiVersion in versionProvider.ApiVersionDescriptions)
            {
                swaggerUIOptions.SwaggerEndpoint($"/{AppDomain.CurrentDomain.FriendlyName.ToLower()}/swagger/v{apiVersion.ApiVersion}/swagger.json", $"{AppDomain.CurrentDomain.FriendlyName} - v{apiVersion.ApiVersion}");
            }

            swaggerUIOptions.RoutePrefix = "swagger";
            swaggerUIOptions.DocExpansion(DocExpansion.List);
        }
        private static void ConfigureSwaggerUI(this SwaggerUIOptions swaggerUIOptions, IApiVersionDescriptionProvider versionProvider)
        {
            var swaggerJsonBasePath = string.IsNullOrWhiteSpace(swaggerUIOptions.RoutePrefix) ? "." : "..";

            foreach (var apiVersion in versionProvider.ApiVersionDescriptions)
            {
                swaggerUIOptions.SwaggerEndpoint($"{swaggerJsonBasePath}/swagger/v{apiVersion.ApiVersion}/swagger.json", $"{ApiName} - v{apiVersion.ApiVersion}");
            }
            swaggerUIOptions.RoutePrefix = string.Empty;
            swaggerUIOptions.DocExpansion(DocExpansion.None);
        }
 /// <summary>
 /// 使用默认SwggerUI
 /// </summary>
 /// <param name="options">SwaggerUI配置</param>
 // ReSharper disable once InconsistentNaming
 public static void UseDefaultSwaggerUI(this SwaggerUIOptions options)
 {
     options.DefaultModelExpandDepth(2);                    // 接口列表折叠配置
     options.DefaultModelRendering(ModelRendering.Example); // 控制首次呈现API时模型的显示方式(模型|示例)。
     options.ShowExtensions();                              // 显示扩展信息
     options.DefaultModelsExpandDepth(-1);                  // 隐藏model
     options.DisplayOperationId();                          // 显示控制器接口方法名
     options.DisplayRequestDuration();                      // 显示请求持续时间(以毫秒为单位)
     options.DocExpansion(DocExpansion.None);               // 文档显示方式:显示控制器
     options.EnableDeepLinking();                           // 启用深层连接,用于指定Url自动跳转到相应标签
     options.EnableFilter();                                // 启用过滤文本框
 }
 /// <summary>
 /// Set up some properties for swagger UI
 /// </summary>
 /// <param name="settings"></param>
 public static void SwaggerSettings(SwaggerUIOptions settings)
 {
     settings.SwaggerEndpoint(SwaggerConfig, $"{AppTitle} v.{AppVersion}");
     settings.RoutePrefix   = SwaggerUrl;
     settings.DocumentTitle = "Microservice API";
     settings.DefaultModelExpandDepth(0);
     settings.DefaultModelRendering(ModelRendering.Model);
     settings.DefaultModelsExpandDepth(0);
     settings.DocExpansion(DocExpansion.None);
     settings.OAuthClientId("microservice1");
     settings.OAuthScopeSeparator(" ");
     settings.OAuthClientSecret("secret");
     settings.DisplayRequestDuration();
     settings.OAuthAppName("Microservice API (with IdentityServer4) module API documentation");
 }
 /// <summary>
 /// Set up some properties for swagger UI
 /// </summary>
 /// <param name="settings"></param>
 public static void SwaggerSettings(SwaggerUIOptions settings)
 {
     settings.SwaggerEndpoint(SwaggerConfig, $"{AppTitle} v.{AppVersion}");
     settings.HeadContent   = $"{ThisAssembly.Git.Branch.ToUpper()} {ThisAssembly.Git.Commit.ToUpper()}";
     settings.DocumentTitle = $"{AppTitle}";
     settings.DefaultModelExpandDepth(0);
     settings.DefaultModelRendering(ModelRendering.Model);
     settings.DefaultModelsExpandDepth(0);
     settings.DocExpansion(DocExpansion.None);
     settings.OAuthClientId("microservice1");
     settings.OAuthScopeSeparator(" ");
     settings.OAuthClientSecret("secret");
     settings.DisplayRequestDuration();
     settings.OAuthAppName("Microservice module API");
 }
Esempio n. 10
0
        internal static void SetSwaggerUIOptions(IApiVersionDescriptionProvider provider, SwaggerUIOptions options)
        {
            foreach (var description in provider.ApiVersionDescriptions)
            {
                if (!description.IsDeprecated)
                {
                    options.SwaggerEndpoint(
                        $"{description.GroupName}/swagger.json",
                        description.GroupName.ToUpperInvariant()
                        );
                }
            }

            options.DocExpansion(DocExpansion.List);
        }
 /// <summary>
 /// Set up some properties for swagger UI
 /// </summary>
 /// <param name="settings"></param>
 public static void SwaggerSettings(SwaggerUIOptions settings)
 {
     settings.SwaggerEndpoint(SwaggerConfig, $"{AppTitle} v.{AppVersion}");
     settings.RoutePrefix   = SwaggerUrl;
     settings.DocumentTitle = "Catalog API documentation";
     settings.DefaultModelExpandDepth(0);
     settings.DefaultModelRendering(ModelRendering.Model);
     settings.DefaultModelsExpandDepth(0);
     settings.DocExpansion(DocExpansion.None);
     settings.OAuthClientId("microservice1");
     settings.OAuthScopeSeparator(" ");
     settings.OAuthClientSecret("secret");
     settings.DisplayRequestDuration();
     settings.OAuthAppName("Micro service");
     settings.OAuthUseBasicAuthenticationWithAccessCodeGrant();
 }
Esempio n. 12
0
 public static SwaggerUIOptions GetSwaggerUIOptions(SwaggerUIOptions options)
 {
     try
     {
         options.SwaggerEndpoint("/swagger/v1/swagger.json", applicationName);
         options.DocumentTitle = applicationName;
         options.DocExpansion(DocExpansion.None);
         options.RoutePrefix = string.Empty;
         return(options);
     }
     catch (Exception ex)
     {
         Logger.LogError("Error in GetSwaggerUIOptions", ex);
         throw ex;
     }
 }
        /// <summary>
        /// Swagger UI 构建
        /// </summary>
        /// <param name="swaggerUIOptions"></param>
        internal static void BuildUI(SwaggerUIOptions swaggerUIOptions)
        {
            // 配置分组终点路由
            CreateGroupEndpoint(swaggerUIOptions);

            // 配置文档标题
            swaggerUIOptions.DocumentTitle = _specificationDocumentSettings.DocumentTitle;

            // 配置UI地址
            swaggerUIOptions.RoutePrefix = _specificationDocumentSettings.RoutePrefix;

            // 文档展开设置
            swaggerUIOptions.DocExpansion(_specificationDocumentSettings.DocExpansionState.Value);

            // 注入 MiniProfiler 组件
            InjectMiniProfilerPlugin(swaggerUIOptions);
        }
Esempio n. 14
0
        /// <summary>
        /// Swagger UI 构建
        /// </summary>
        /// <param name="swaggerUIOptions"></param>
        /// <param name="routePrefix"></param>
        /// <param name="configure"></param>
        internal static void BuildUI(SwaggerUIOptions swaggerUIOptions, string routePrefix = default, Action <SwaggerUIOptions> configure = null)
        {
            // 配置分组终点路由
            CreateGroupEndpoint(swaggerUIOptions);

            // 配置文档标题
            swaggerUIOptions.DocumentTitle = _specificationDocumentSettings.DocumentTitle;

            // 配置UI地址
            swaggerUIOptions.RoutePrefix = _specificationDocumentSettings.RoutePrefix ?? routePrefix ?? "api";

            // 文档展开设置
            swaggerUIOptions.DocExpansion(_specificationDocumentSettings.DocExpansionState.Value);

            // 注入 MiniProfiler 组件
            InjectMiniProfilerPlugin(swaggerUIOptions);

            // 自定义配置
            configure?.Invoke(swaggerUIOptions);
        }