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 providing multiple BeforeScript and AfterScript #80

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

Conversation

Zhomart
Copy link

@Zhomart Zhomart commented Jan 13, 2023

Allow providing multiple BeforeScript and AfterScript

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 #81

Test Plan: Updated existing example and tests. Added new test TestMultipleScripts


Stack created with Sapling. Best reviewed with ReviewStack.

@Zhomart Zhomart changed the title placeholder for pull request Allow providing multiple BeforeScript and AfterScript 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 marked this pull request as ready for review January 13, 2023 21:50
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.

Allow supporting multiple BeforeScript and AfterScript configs
1 participant