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 supporting multiple BeforeScript and AfterScript configs #81

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

Allow supporting multiple BeforeScript and AfterScript configs #81

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

Comments

@Zhomart
Copy link

Zhomart commented Jan 13, 2023

Currently these configs just replace the previous script, example:

	r.Get("/swagger/*", httpSwagger.Handler(
		httpSwagger.BeforeScript("console.log('before 1')"),
		httpSwagger.BeforeScript("console.log('before 2')"),
		httpSwagger.URL("http://localhost:1323/swagger/doc.json"), //The url pointing to API definition
	))

	// Only 'before 2' is printed

It makes hard to add multiple configuration scripts by forcing joing strings.

Zhomart added a commit to Zhomart/http-swagger that referenced this issue Jan 13, 2023
Summary:

Previsouly this code would allow only a single script to run:

```
	r.Get("/swagger/*", httpSwagger.Handler(
		httpSwagger.BeforeScript("console.log('before 1')"),
		httpSwagger.BeforeScript("console.log('before 2')"),
		httpSwagger.URL("http://localhost:1323/swagger/doc.json"), //The url pointing to API definition
	))

	// Only 'before 2' will be printed
```

Now both scripts are run:

```
'before 1'
'before 2'
```

This improves behavior of BeforeScript and AfterScript. If users
want to provide multiple scripts, they are forced to combine them using
strings.

Closes swaggo#81

Test Plan: Updated existing example and tests. Added new test TestMultipleScripts
@Zhomart Zhomart linked a pull request Jan 13, 2023 that will close this issue
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