Skip to content

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