-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds a setting-option to add swagger plugins. #4922
base: master
Are you sure you want to change the base?
Conversation
resolves #4921 |
Fixes #4921 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please merge latest master branch and fix conflicts after https://github.com/RicoSuter/NSwag/pull/5031/files
@@ -59,7 +62,8 @@ | |||
], | |||
plugins: [ | |||
SwaggerUIBundle.plugins.DownloadUrl, | |||
disableTryItOutPlugin | |||
disableTryItOutPlugin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
disableTryItOutPlugin | |
disableTryItOutPlugin, |
|
||
{PluginScripts} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{PluginScripts} | |
{PluginScripts} |
@@ -60,6 +62,7 @@ | |||
plugins: [ | |||
SwaggerUIBundle.plugins.DownloadUrl, | |||
disableTryItOutPlugin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
disableTryItOutPlugin | |
disableTryItOutPlugin, |
|
||
{PluginScripts} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{PluginScripts} | |
{PluginScripts} |
.Replace("{DocumentTitle}", DocumentTitle) | ||
.Replace("{AdditionalPlugins}", GeneratePluginsList(AdditionalPlugins.Keys.ToArray())) | ||
.Replace("{PluginScripts}", GetCustomScripts(AdditionalPlugins.Values.ToArray(), request)); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -16,6 +16,8 @@ | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Threading; | |||
using System.Runtime.CompilerServices; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protected string GetCustomScripts(string[] scriptPaths, HttpRequest request) | ||
#endif | ||
{ | ||
if ((scriptPaths == null )|| (scriptPaths.Count()==0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ((scriptPaths == null )|| (scriptPaths.Count()==0)) | |
if ((scriptPaths == null ) || (scriptPaths.Count() == 0)) |
|
||
return builder.ToString(); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// <param name="pluginsList"></param> | ||
/// <returns></returns> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// <param name="pluginsList"></param> | |
/// <returns></returns> |
@@ -132,5 +157,21 @@ protected string GenerateAdditionalSettings(IDictionary<string, object> addition | |||
|
|||
return code; | |||
} | |||
|
|||
/// <summary> | |||
/// Generates the JavaScript plugins object to inset into the html. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Generates the JavaScript plugins object to inset into the html. | |
/// Generates the JavaScript plugins object to inset into the HTML. |
To link PR and issues, this text needs to be in the first comment. |
I wanted a way to add swagger plugins through NSwag.
Changed the signature of GetCustomScriptHtml to allow reuse.
Added setting for plugin with name and script path.
Script must be hosted in your application and reachable by swagger.