Пример #1
0
        /// <summary>
        /// Adds Swagger JSON endpoints. Can be fully-qualified or relative to the UI page
        /// </summary>
        /// <param name="options"></param>
        /// <param name="url">Can be fully qualified or relative to the current host</param>
        /// <param name="name">The description that appears in the document selector drop-down</param>
        public static void SwaggerEndpoint(this SwaggerBootstrapUIOptions options, string url, string name)
        {
            var urls = new List <UrlDescriptor>(options.ConfigObject.Urls ?? Enumerable.Empty <UrlDescriptor>())
            {
                new UrlDescriptor {
                    url = url, name = name
                }
            };

            options.ConfigObject.Urls = urls;
        }
Пример #2
0
        public static IApplicationBuilder UseSwaggerBootstrapUI(
            this IApplicationBuilder app,
            Action <SwaggerBootstrapUIOptions> setupAction = null)
        {
            if (setupAction == null)
            {
                // Don't pass options so it can be configured/injected via DI container instead
                app.UseMiddleware <SwaggerBootstrapUIMiddleware>();
            }
            else
            {
                // Configure an options instance here and pass directly to the middleware
                var options = new SwaggerBootstrapUIOptions();
                setupAction.Invoke(options);

                app.UseMiddleware <SwaggerBootstrapUIMiddleware>(options);
            }

            return(app);
        }