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

Allow adding external scripts to the index.html #83

Open
Zhomart opened this issue Jan 13, 2023 · 0 comments · May be fixed by #82
Open

Allow adding external scripts to the index.html #83

Zhomart opened this issue Jan 13, 2023 · 0 comments · May be fixed by #82

Comments

@Zhomart
Copy link

Zhomart commented Jan 13, 2023

Currently these is no way to add more <script src="local or extern"> </script> tags. Having this is useful to add local or external swagger-ui plugins.

I'm thinking of this kind of config

	r.Get("/swagger/*", httpSwagger.Handler(
		httpSwagger.ScriptSrc("https://unpkg.com/[email protected]/dist/htm.js"),
		httpSwagger.ScriptSrc("https://unpkg.com/[email protected]/umd/react.production.min.js"),
		httpSwagger.ScriptSrc("/static/myplugin.js"),
		httpSwagger.Plugins([]string{"MyPlugin"}),
		httpSwagger.URL("http://localhost:1323/swagger/doc.json"), //The url pointing to API definition
	))
Zhomart added a commit to Zhomart/http-swagger that referenced this issue Jan 13, 2023
Summary: This allows importing plugins from local and external hosts.

```
	r.Get("/swagger/*", httpSwagger.Handler(
		httpSwagger.ScriptSrc("/static/swagger-helper.js"),
		httpSwagger.ScriptSrc("https://unpkg.com/[email protected]/build/index.js"),
		httpSwagger.Plugins([]string{"DisableTryItOutWithoutServersPlugin"},
		httpSwagger.URL("http://localhost:1323/swagger/doc.json"), //The url pointing to API definition
	))
```

Closes swaggo#83

Test Plan: Updated existing tests. Added example in example/go-chi/
@Zhomart Zhomart linked a pull request Jan 13, 2023 that will close this issue
Zhomart added a commit to Zhomart/http-swagger that referenced this issue Jan 13, 2023
Summary: This allows importing plugins from local and external hosts.

```
	r.Get("/swagger/*", httpSwagger.Handler(
		httpSwagger.ScriptSrc("/static/swagger-helper.js"),
		httpSwagger.ScriptSrc("https://unpkg.com/[email protected]/build/index.js"),
		httpSwagger.Plugins([]string{"DisableTryItOutWithoutServersPlugin"},
		httpSwagger.URL("http://localhost:1323/swagger/doc.json"), //The url pointing to API definition
	))
```

Closes swaggo#83

Test Plan: Updated existing tests. Added example in example/go-chi/
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 a pull request may close this issue.

1 participant