Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jarleli
Copy link

@jarleli jarleli commented Jun 24, 2024

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.

@jarleli
Copy link
Author

jarleli commented Jun 24, 2024

resolves #4921

@jarleli
Copy link
Author

jarleli commented Jun 26, 2024

Fixes #4921

Copy link
Contributor

@Saibamen Saibamen left a 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
disableTryItOutPlugin
disableTryItOutPlugin,

Comment on lines +20 to +22

{PluginScripts}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{PluginScripts}
{PluginScripts}

@@ -60,6 +62,7 @@
plugins: [
SwaggerUIBundle.plugins.DownloadUrl,
disableTryItOutPlugin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
disableTryItOutPlugin
disableTryItOutPlugin,

Comment on lines +20 to +21

{PluginScripts}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{PluginScripts}
{PluginScripts}

.Replace("{DocumentTitle}", DocumentTitle)
.Replace("{AdditionalPlugins}", GeneratePluginsList(AdditionalPlugins.Keys.ToArray()))
.Replace("{PluginScripts}", GetCustomScripts(AdditionalPlugins.Values.ToArray(), request));

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

@@ -16,6 +16,8 @@
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.Runtime.CompilerServices;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

protected string GetCustomScripts(string[] scriptPaths, HttpRequest request)
#endif
{
if ((scriptPaths == null )|| (scriptPaths.Count()==0))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ((scriptPaths == null )|| (scriptPaths.Count()==0))
if ((scriptPaths == null ) || (scriptPaths.Count() == 0))


return builder.ToString();
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Comment on lines +164 to +165
/// <param name="pluginsList"></param>
/// <returns></returns>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// <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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Generates the JavaScript plugins object to inset into the html.
/// Generates the JavaScript plugins object to inset into the HTML.

@Saibamen
Copy link
Contributor

Fixes #4921

To link PR and issues, this text needs to be in the first comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants