Пример #1
0
 public virtual void SetupSwaggerCommonUi(SwaggerUIOptions options)
 {
     options.EnableDeepLinking();
     options.EnableFilter();
     options.DocumentTitle = $"{this.MicroServiceTitle} - Swagger UI";
     options.RoutePrefix   = SwaggerUiRoutePrefix;
     options.HeadContent  += "<meta name=\"robots\" content=\"none\" />";
     options.OAuthClientId(Configuration.GetValue <string>("SwaggerClientId"));
     options.OAuthClientSecret(Configuration.GetValue <string>("SwaggerClientSecret"));
     options.OAuthAppName(Configuration.GetValue <string>("SwaggerAppName"));
     options.OAuthScopeSeparator(" ");
     options.OAuthUsePkce();
 }
        public static void SetupSwaggerUIOptions(this SwaggerUIOptions options)
        {
            options.DocumentTitle = "ProjectName BoundedContext Api V1 Docs";
            options.RoutePrefix   = "docs";
            options.SwaggerEndpoint("/docs/v1/json", "ProjectName BoundedContext Api V1 Docs");
            options.SwaggerEndpoint("/docs/admin-v1/json", "ProjectName BoundedContext Admin Api V1 Docs");
            options.IndexStream = () => Assembly.GetExecutingAssembly()
                                  .GetManifestResourceStream("BoundedContext.Api.Swagger.CustomUI.index.html");

            options.OAuthClientId("resourceowner");
            options.OAuthClientSecret("TPOAuthClientSecret");
            options.OAuthRealm("realm");
            options.OAuthAppName("BoundedContext");
        }
 /// <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");
 }
        private static void InitUIOption(SwaggerUIOptions c, SwaggerForOCelotUIOptions options, InnerSaceAPI api)
        {
            c.ConfigObject      = options.ConfigObject;
            c.DocumentTitle     = options.DocumentTitle;
            c.HeadContent       = options.HeadContent;
            c.IndexStream       = options.IndexStream;
            c.OAuthConfigObject = options.OAuthConfigObject;
            c.RoutePrefix       = options.RoutePrefix;

            options.InjectJavascript("Swaggerinit.js");
            //c.RoutePrefix = string.Empty;
            //c.SwaggerEndpoint("/swagger/v1/swagger.json", "Messages service getaway API V1");
            c.OAuthClientId(api.ClientId);
            c.OAuthAppName(api.Name);
        }
 /// <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();
 }
Пример #7
0
        public virtual void SetupSwaggerUI(SwaggerUIOptions options, IApiVersionDescriptionProvider provider)
        {
            var swaggerJsonRoutePrefix = string.IsNullOrEmpty(SwaggerUiRoutePrefix) ? "./swagger" : ".";

            foreach (var description in provider.ApiVersionDescriptions)
            {
                options.SwaggerEndpoint($"{swaggerJsonRoutePrefix}/{description.GroupName}/swagger.json", description.GroupName.ToUpperInvariant());
            }
            options.EnableDeepLinking();
            options.EnableFilter();
            options.RoutePrefix  = SwaggerUiRoutePrefix;
            options.HeadContent += "<meta name=\"robots\" content=\"none\" />";
            options.OAuthClientId(Configuration.GetValue <string>("SwaggerClientId"));
            options.OAuthClientSecret(Configuration.GetValue <string>("SwaggerClientSecret"));
            options.OAuthAppName(Configuration.GetValue <string>("SwaggerAppName"));
            options.OAuthScopeSeparator(" ");
            options.OAuthUsePkce();
        }
Пример #8
0
        public static void ConfigureAuth(this SwaggerUIOptions options, AppInfo appInfo,
                                         AuthenticationInfo authentication)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }
            if (authentication == null)
            {
                throw new ArgumentNullException(nameof(authentication));
            }

            options.OAuthClientId(authentication.Audience);
            options.OAuthAppName(appInfo.Name);
            options.OAuthAdditionalQueryStringParams(new Dictionary <string, string>
            {
                { "resource", authentication.Audience }
            });
        }