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

SwaggerUI Bundle request/response interceptors #635

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

tpwalke2
Copy link

@tpwalke2 tpwalke2 commented Dec 20, 2023

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 the ISwaggerUI interface. This solution would have also required a new default implementation, a new resolver, an update to the IOpenApiHttpTriggerContext interface and OpenApiHttpTriggerContext class.

The additional spread of the change required for the second solution seemed to be more complicated than updating the IOpenApiCustomUIOptions interface.

@tpwalke2
Copy link
Author

@microsoft-github-policy-service agree

@tpwalke2 tpwalke2 changed the title Bundle interceptors SwaggerUI Bundle request/response interceptors Dec 20, 2023
@tpwalke2 tpwalke2 marked this pull request as ready for review December 20, 2023 18:17
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.

1 participant