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 InjectJavascript and InjectStylesheet on the UseSwaggerForOcelotUI method #299

Closed
pvanhooren opened this issue Jun 13, 2024 Discussed in #298 · 1 comment
Closed

Comments

@pvanhooren
Copy link

Discussed in #298

Originally posted by pvanhooren June 12, 2024
I am currently in the process of writing a second API application in our microservices codebase and I stumbled upon this package when researching how to combine two Swagger documentation pages.

I have set everything up to create the combined Swagger page with version selector and all, but now I can't find the option to inject
my own stylesheet and JavaScript file to customize the documentation. Our current Swagger page does have custom CSS and JavaScript, so I'd rather have it on our new combined one as well.

Now I cannot find the extension method in UseSwaggerForOcelotUI , which I assumed to be the substitution of UseSwaggerUI, which does support these extension methods. Therefore I assume this feature is not (yet) supported. I'd also love to hear if that's wrong and if there's a workaround. But if not, I'd like to suggest the idea of adding this here as it would be very helpful for my case and probably many others :)

Here's what I expect to be able to do:

app.UseSwaggerForOcelotUI(opt =>
{
       opt.InjectStylesheet("/swagger-ui/swagger.min.css");
       opt.InjectJavascript("/swagger-ui/swagger.js");
}).UseOcelot().Wait();

or something along those lines. Again, I'm open for workarounds too, please join the discussion if you have anything to say on this topic!

@Burgyn
Copy link
Owner

Burgyn commented Jun 19, 2024

Hi @pvanhooren,

try to use overload method with setupAction.
Something like:

app.UseSwaggerForOcelotUI(opt =>
{
    // configure OcelotSwaggerUIOptions
}, setup =>
{
    // configure SwaggerUIOptions
    // 👇 this is place for you
    setup.InjectJavascript("/swagger-ui/custom.js");
    setup.InjectStylesheet("/swagger-ui/custom.css");
}).UseOcelot().Wait();

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

No branches or pull requests

2 participants