Skip to content

Commit

Permalink
Add setting to set ReDoc page title (#2796) (#4581)
Browse files Browse the repository at this point in the history
Same logic as in `SwaggerUiSettings`

Co-authored-by: BÈCLE Hadrien <[email protected]>
  • Loading branch information
hadrienbecle and BÈCLE Hadrien authored Nov 14, 2023
1 parent 4002f3a commit a7cea58
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/NSwag.AspNet.Owin/ReDoc/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>ReDoc</title>
<title>{DocumentTitle}</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700" rel="stylesheet">
Expand Down
2 changes: 1 addition & 1 deletion src/NSwag.AspNetCore/ReDoc/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>ReDoc</title>
<title>{DocumentTitle}</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700" rel="stylesheet">
Expand Down
6 changes: 6 additions & 0 deletions src/NSwag.AspNetCore/ReDocSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ public class ReDocSettings : SwaggerUiSettingsBase
/// <summary>Gets the additional ReDoc settings.</summary>
public IDictionary<string, object> AdditionalSettings { get; } = new Dictionary<string, object>();

/// <summary>
/// Gets or sets a title for the ReDoc page.
/// </summary>
public string DocumentTitle { get; set; } = "ReDoc";

#if AspNetOwin
internal override Task<string> TransformHtmlAsync(string html, IOwinRequest request, CancellationToken cancellationToken)
#else
Expand All @@ -40,6 +45,7 @@ internal override Task<string> TransformHtmlAsync(string html, HttpRequest reque
html = html.Replace("{AdditionalSettings}", GenerateAdditionalSettings(AdditionalSettings));
html = html.Replace("{CustomStyle}", GetCustomStyleHtml(request));
html = html.Replace("{CustomScript}", GetCustomScriptHtml(request));
html = html.Replace("{DocumentTitle}", DocumentTitle);
return Task.FromResult(html);
}
}
Expand Down

0 comments on commit a7cea58

Please sign in to comment.