コード例 #1
0
        internal override string TransformHtml(string html, HttpRequest request)
#endif
        {
            var oauth2Settings = OAuth2Client ?? new OAuth2ClientSettings();

            foreach (var property in oauth2Settings.GetType().GetRuntimeProperties())
            {
                var value = property.GetValue(oauth2Settings);
                html = html.Replace("{" + property.Name + "}", value is IDictionary ? JsonConvert.SerializeObject(value) : value?.ToString() ?? "");
            }

            html = html.Replace("{Urls}", !SwaggerRoutes.Any() ?
                                "undefined" :
                                JsonConvert.SerializeObject(
                                    SwaggerRoutes.Select(r => new SwaggerUi3Route(r.Name, TransformToExternalPath(r.Url.Substring(MiddlewareBasePath?.Length ?? 0), request)))
                                    ));

            html = html.Replace("{ValidatorUrl}", ValidateSpecification ? "undefined" : "null");
            html = html.Replace("{DocExpansion}", DocExpansion);
            html = html.Replace("{OperationsSorter}", OperationsSorter);
            html = html.Replace("{DefaultModelsExpandDepth}", DefaultModelsExpandDepth.ToString());
            html = html.Replace("{DefaultModelExpandDepth}", DefaultModelExpandDepth.ToString());
            html = html.Replace("{TagsSorter}", TagsSorter);
            html = html.Replace("{EnableTryItOut}", EnableTryItOut.ToString().ToLower());
            html = html.Replace("{RedirectUrl}", string.IsNullOrEmpty(ServerUrl) ?
                                "window.location.origin + \"" + TransformToExternalPath(Path, request) + "/oauth2-redirect.html\"" :
                                "\"" + ServerUrl + TransformToExternalPath(Path, request) + "/oauth2-redirect.html\"");
            html = html.Replace("{StylesheetUri}", CustomStylesheetUri?.ToString() ?? "");
            html = html.Replace("{ScriptUri}", CustomJavaScriptUri?.ToString() ?? "");

            return(html);
        }
コード例 #2
0
        internal override string TransformHtml(string html, HttpRequest request)
#endif
        {
            var oauth2Settings = OAuth2Client ?? new OAuth2ClientSettings();

            foreach (var property in oauth2Settings.GetType().GetRuntimeProperties())
            {
                var value = property.GetValue(oauth2Settings);
                html = html.Replace("{" + property.Name + "}", value is IDictionary ? JsonConvert.SerializeObject(value) : value?.ToString() ?? "");
            }

            html = html.Replace("{ValidatorUrl}", ValidateSpecification ? "undefined" : "null");
            html = html.Replace("{DocExpansion}", DocExpansion);
            html = html.Replace("{SupportedSubmitMethods}", JsonConvert.SerializeObject(SupportedSubmitMethods ?? new string[] { }));
            html = html.Replace("{UseJsonEditor}", UseJsonEditor ? "true" : "false");
            html = html.Replace("{DefaultModelRendering}", DefaultModelRendering);
            html = html.Replace("{ShowRequestHeaders}", ShowRequestHeaders ? "true" : "false");
            html = html.Replace("{StylesheetUri}", CustomStylesheetUri?.ToString() ?? "");
            html = html.Replace("{ScriptUri}", CustomJavaScriptUri?.ToString() ?? "");

            return(html);
        }