コード例 #1
0
        /// <summary>
        /// Injects additional CSS stylesheets into the index.html page
        /// </summary>
        /// <param name="options"></param>
        /// <param name="path">A path to the stylesheet - i.e. the link "href" attribute</param>
        /// <param name="media">The target media - i.e. the link "media" attribute</param>
        public static void InjectStylesheet(this ReDocOptions options, string path, string media = "screen")
        {
            var builder = new StringBuilder(options.HeadContent);

            builder.AppendLine($"<link href='{path}' rel='stylesheet' media='{media}' type='text/css' />");
            options.HeadContent = builder.ToString();
        }
コード例 #2
0
        /// <summary>
        /// Register the ReDoc middleware with provided options
        /// </summary>
        public static IApplicationBuilder UseReDoc(this IApplicationBuilder app, Action <ReDocOptions> setupAction)
        {
            var options = new ReDocOptions();

            setupAction(options);

            return(app.UseReDoc(options));
        }
コード例 #3
0
        /// <summary>
        /// Register the ReDoc middleware with provided options
        /// </summary>
        public static IApplicationBuilder UseReDoc(this IApplicationBuilder app, ReDocOptions options)
        {
            // To simplify the common case, use a default that will work with the SwaggerMiddleware defaults
            if (options.SpecUrl == null)
            {
                options.SpecUrl = "/swagger/v1/swagger.json";
            }

            return(app.UseMiddleware <ReDocMiddleware>(options));
        }
コード例 #4
0
        public static IApplicationBuilder UseReDoc(
            this IApplicationBuilder app,
            Action <ReDocOptions> setupAction)
        {
            var options = new ReDocOptions();

            setupAction?.Invoke(options);

            app.UseMiddleware <ReDocIndexMiddleware>(options);
            app.UseFileServer(new FileServerOptions
            {
                RequestPath             = string.IsNullOrEmpty(options.RoutePrefix) ? string.Empty : $"/{options.RoutePrefix}",
                FileProvider            = new EmbeddedFileProvider(typeof(ReDocBuilderExtensions).GetTypeInfo().Assembly, EmbeddedFilesNamespace),
                EnableDirectoryBrowsing = true // will redirect to /{options.RoutePrefix}/ when trailing slash is missing
            });

            return(app);
        }
コード例 #5
0
        public static IApplicationBuilder UseReDoc(
            this IApplicationBuilder app,
            Action <ReDocOptions> setupAction = null)
        {
            var options = new ReDocOptions();

            if (setupAction != null)
            {
                setupAction(options);
            }
            else
            {
                options = app.ApplicationServices.GetRequiredService <IOptions <ReDocOptions> >().Value;
            }

            app.UseMiddleware <ReDocMiddleware>(options);

            return(app);
        }
コード例 #6
0
        public static IApplicationBuilder UseReDoc(
            this IApplicationBuilder app,
            Action <ReDocOptions> setupAction = null)
        {
            if (setupAction == null)
            {
                // Don't pass options so it can be configured/injected via DI container instead
                app.UseMiddleware <ReDocMiddleware>();
            }
            else
            {
                // Configure an options instance here and pass directly to the middleware
                var options = new ReDocOptions();
                setupAction.Invoke(options);

                app.UseMiddleware <ReDocMiddleware>(options);
            }

            return(app);
        }
コード例 #7
0
 /// <summary>
 /// Do not inject Authentication section automatically
 /// </summary>
 public static void NoAutoAuth(this ReDocOptions options)
 {
     options.ConfigObject.NoAutoAuth = true;
 }
コード例 #8
0
 /// <summary>
 /// Specify which responses to expand by default by response codes.
 /// Values should be passed as comma-separated list without spaces e.g. "200,201". Special value "all" expands all responses by default.
 /// Be careful: this option can slow-down documentation rendering time.
 /// Default is "all"
 /// </summary>
 public static void ExpandResponses(this ReDocOptions options, string responses)
 {
     options.ConfigObject.ExpandResponses = responses;
 }
コード例 #9
0
 /// <summary>
 /// Show required properties first ordered in the same order as in required array
 /// </summary>
 public static void RequiredPropsFirst(this ReDocOptions options)
 {
     options.ConfigObject.RequiredPropsFirst = true;
 }
コード例 #10
0
 /// <summary>
 /// Controls if the protocol and hostname is shown in the operation definition
 /// </summary>
 public static void HideHostname(this ReDocOptions options)
 {
     options.ConfigObject.HideHostname = true;
 }
コード例 #11
0
 /// <summary>
 /// Do not show "Download" spec button. THIS DOESN'T MAKE YOUR SPEC PRIVATE, it just hides the button
 /// </summary>
 public static void HideDownloadButton(this ReDocOptions options)
 {
     options.ConfigObject.HideDownloadButton = true;
 }
コード例 #12
0
 /// <summary>
 /// If enabled, the spec is considered untrusted and all HTML/markdown is sanitized to prevent XSS.
 /// Disabled by default for performance reasons. Enable this option if you work with untrusted user data!
 /// </summary>
 /// <param name="options"></param>
 public static void EnableUntrustedSpec(this ReDocOptions options)
 {
     options.ConfigObject.UntrustedSpec = true;
 }
コード例 #13
0
 /// <summary>
 /// Specifies a vertical scroll-offset in pixels.
 /// This is often useful when there are fixed positioned elements at the top of the page, such as navbars, headers etc
 /// </summary>
 /// <param name="options"></param>
 /// <param name="offset"></param>
 public static void ScrollYOffset(this ReDocOptions options, int offset)
 {
     options.ConfigObject.ScrollYOffset = offset;
 }
コード例 #14
0
 void IConfigureOptions <ReDocOptions> .Configure(ReDocOptions options)
 {
 }
コード例 #15
0
 /// <summary>
 /// Sets the Swagger JSON endpoint. Can be fully-qualified or relative to the redoc page
 /// </summary>
 public static void SpecUrl(this ReDocOptions options, string url)
 {
     options.SpecUrl = url;
 }
コード例 #16
0
 /// <summary>
 /// Show path link and HTTP verb in the middle panel instead of the right one
 /// </summary>
 public static void PathInMiddlePanel(this ReDocOptions options)
 {
     options.ConfigObject.PathInMiddlePanel = true;
 }
コード例 #17
0
 /// <summary>
 /// Show only required fields in request samples
 /// </summary>
 public static void OnlyRequiredInSamples(this ReDocOptions options)
 {
     options.ConfigObject.OnlyRequiredInSamples = true;
 }
コード例 #18
0
 /// <summary>
 /// Disable search indexing and search box
 /// </summary>
 public static void DisableSearch(this ReDocOptions options)
 {
     options.ConfigObject.DisableSearch = true;
 }
コード例 #19
0
 /// <summary>
 /// Use native scrollbar for sidemenu instead of perfect-scroll (scrolling performance optimization for big specs)
 /// </summary>
 public static void NativeScrollbars(this ReDocOptions options)
 {
     options.ConfigObject.NativeScrollbars = true;
 }
コード例 #20
0
 /// <summary>
 /// Do not show loading animation. Useful for small docs
 /// </summary>
 public static void HideLoading(this ReDocOptions options)
 {
     options.ConfigObject.HideLoading = true;
 }
コード例 #21
0
 /// <summary>
 /// Register the ReDoc middleware with provided options
 /// </summary>
 public static IApplicationBuilder UseReDoc(this IApplicationBuilder app, ReDocOptions options)
 {
     return(app.UseMiddleware <ReDocMiddleware>(options));
 }
コード例 #22
0
 /// <summary>
 /// Sort properties alphabetically
 /// </summary>
 public static void SortPropsAlphabetically(this ReDocOptions options)
 {
     options.ConfigObject.SortPropsAlphabetically = true;
 }