Пример #1
0
 public RedocFoldersAsTagGroupsFilesAsTagsDocFilter(IHttpContextAccessor hcx, IWikiMarkdownHandler markdownHandler, IOptions <RedocUiOptions> options, IOptions <SwaggerDocOptions> docOptions)
 {
     this.hcx             = hcx ?? throw new System.ArgumentNullException(nameof(hcx));
     this.markdownHandler = markdownHandler ?? throw new System.ArgumentNullException(nameof(markdownHandler));
     this.options         = options?.Value ?? throw new System.ArgumentNullException(nameof(options));
     this.docOptions      = docOptions?.Value ?? throw new System.ArgumentNullException(nameof(docOptions));
 }
 internal ReallySimpleDocumentationApplicationBuilder(IApplicationBuilder app, SwaggerDocOptions options)
 {
     this.app     = app;
     this.options = options;
 }
 public SwaggerDocFilter(IHttpContextAccessor hcx, IOptions <SwaggerDocOptions> options)
 {
     this.hcx     = hcx ?? throw new System.ArgumentNullException(nameof(hcx));
     this.options = options?.Value ?? throw new System.ArgumentNullException(nameof(options));
 }
Пример #4
0
 public SwaggerUIDocFilter(IHttpContextAccessor hcx, ISwaggerUIWikiFactory wikiFactory, IOptions <SwaggerDocOptions> docOptions)
 {
     this.hcx         = hcx;
     this.wikiFactory = wikiFactory;
     this.docOptions  = docOptions?.Value;
 }
Пример #5
0
        internal static string ReplaceApiTemplateVariables(this string input, IUIOptions config, SwaggerDocOptions options)
        {
            var css = new List <string>(config.AdditionalStylesheets.Where(x => !string.IsNullOrWhiteSpace(x)));

            if (config.ServeDefaultCss)
            {
                css.Add(config.DefaultCssRoute);
            }
            css = css.Select(x => $"<link rel='stylesheet' href='{x}'>").ToList();

            var js = new List <string>(config.AdditionalJavascript.Where(x => !string.IsNullOrWhiteSpace(x)));

            if (config.ServeDefaultJavascript)
            {
                js.Add(config.DefaultJavascriptRoute);
            }
            js = js.Select(x => $"<script src='{x}'></script>").ToList();

            var favIconElement = string.IsNullOrWhiteSpace(config.FaviconUrl) ? string.Empty : $"<link rel='icon' href='{config.FaviconUrl}'>";

            if (config is RedocUiOptions ruio)
            {
                input = input.Replace("{{RedocBundleUrl}}", ruio.RedocBundleUrl);
            }

            return(input.Replace("{{ApiShortName}}", options.ShortName)
                   .Replace("{{ApiTitle}}", options.Title)
                   .Replace("{{ApiDescription}}", options.DefaultDescription)
                   .Replace("{{FavIconUrl}}", config.FaviconUrl ?? string.Empty)
                   .Replace("{{FavIconElement}}", favIconElement)
                   .Replace("{{LogoUrl}}", config.LogoUrl)
                   .Replace("{{LogoAltText}}", config.LogoAltText)
                   .Replace("{{LogoBackgroundColor}}", config.LogoBackgroundColor)
                   .Replace("{{CssElement}}", string.Join(Environment.NewLine, css))
                   .Replace("{{ScriptElement}}", string.Join(Environment.NewLine, js)));
        }