SwaggerUI Bundle request/response interceptors #635
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is motivated by a need for supporting Auth0's additional requirements when generating access tokens. An additional parameter must be sent in the token request.
The SwaggerUI object allows passing in functions that intercept the request and response objects. The Swashbuckle.AspNetCore.Swagger project allows access to these functions via a builder extension method (https://github.com/domaindrivendev/Swashbuckle.AspNetCore/blob/8f363f7359cb1cb8fa5de5195ec6d97aefaa16b3/src/Swashbuckle.AspNetCore.SwaggerUI/SwaggerUIOptionsExtensions.cs#L321C4-L321C4).
I chose to follow the same replacement strategy as the custom CSS and custom Javascript. I added 2 methods to the
IOpenApiCustomUIOptions
interface and implemented them as empty strings in the default implementation.The downside to this method is that it is a breaking change for any downstream implementations of
IOpenApiCustomUIOptions
.I also considered a solution of adding a new options class and passing it to the
ISwaggerUI.BuildAsync
method. However, this would have represented a breaking change to theISwaggerUI
interface. This solution would have also required a new default implementation, a new resolver, an update to theIOpenApiHttpTriggerContext
interface andOpenApiHttpTriggerContext
class.The additional spread of the change required for the second solution seemed to be more complicated than updating the
IOpenApiCustomUIOptions
interface.